Skip to content

Commit 54e8d2e

Browse files
committed
Merge pull request #16 from msg7086/master
Rewrite load_file to use IO instead of StringIO. Way faster.
2 parents 9fa7f81 + f8eea84 commit 54e8d2e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/bencode/decode.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def self.load(str, opts = {})
3131
# @option (see .load)
3232
# @return (see .load)
3333
def self.load_file(path, opts = {})
34-
load(File.open(path, 'rb').read, opts)
34+
File.open(path, 'rb') do |io|
35+
load(io, opts)
36+
end
3537
end
3638
end

0 commit comments

Comments
 (0)