Skip to content

Commit 5f6abff

Browse files
Refactor Buffering consume_rbuff and getbyte methods
Prefer ``slice!`` for ``Buffering#consume_rbuff`` and safe navigation with ``ord`` for ``Buffering#getbyte``, similar to ``each_byte``.
1 parent c263cd4 commit 5f6abff

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/openssl/buffering.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ def consume_rbuff(size=nil)
9393
nil
9494
else
9595
size = @rbuffer.size unless size
96-
ret = @rbuffer[0, size]
97-
@rbuffer[0, size] = ""
98-
ret
96+
@rbuffer.slice!(0, size)
9997
end
10098
end
10199

@@ -106,8 +104,7 @@ def consume_rbuff(size=nil)
106104
#
107105
# Get the next 8bit byte from `ssl`. Returns `nil` on EOF
108106
def getbyte
109-
byte = read(1)
110-
byte && byte.unpack1("C")
107+
read(1)&.ord
111108
end
112109

113110
##

0 commit comments

Comments
 (0)