Skip to content

Commit a7a3fc4

Browse files
committed
Improved code
1 parent d3be552 commit a7a3fc4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/xgboost/utils.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ def string_pointer(value)
2323
end
2424

2525
def from_cstr_to_rbstr(data, length)
26-
res = []
27-
length.read_uint64.times do |i|
28-
res << data.read_pointer.get_pointer(i * ::FFI::Pointer.size).read_string.force_encoding(Encoding::UTF_8)
26+
data.read_pointer.read_array_of_pointer(length.read_uint64).map do |ptr|
27+
ptr.read_string.force_encoding(Encoding::UTF_8)
2928
end
30-
res
3129
end
3230
end
3331
end

0 commit comments

Comments
 (0)