Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Prefer String#slice for better compatibility. Fixes #72. (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix authored Nov 17, 2023
1 parent f451a33 commit bcf5185
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/async/io/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def peek(size = nil)
# Don't read less than @block_size to avoid lots of small reads:
fill_read_buffer(read_size > @block_size ? read_size : @block_size)
end
return @read_buffer[..([size, @read_buffer.size].min - 1)]
return @read_buffer.slice(0, [size, @read_buffer.size].min)
end
until (block_given? && yield(@read_buffer)) or @eof
fill_read_buffer
Expand Down

0 comments on commit bcf5185

Please sign in to comment.