lib/libmf/model.rb in libmf-0.2.1 vs lib/libmf/model.rb in libmf-0.2.2

- old
+ new

@@ -109,13 +109,14 @@ raise Error, "No data" if data.empty? # TODO do in C for better performance # can use FIX2INT() and RFLOAT_VALUE() instead of pack + # and write directly to C string buffer = String.new + pack_format = "iif" data.each do |row| - row[0, 2].pack("i*".freeze, buffer: buffer) - row[2, 1].pack("f".freeze, buffer: buffer) + row.pack(pack_format, buffer: buffer) end r = ::FFI::MemoryPointer.new(FFI::Node, data.size) r.write_bytes(buffer)