[ruby/openssl] 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``.

https://github.com/ruby/openssl/commit/5f6abff178
This commit is contained in:
Mau Magnaguagno 2022-12-26 08:35:54 -03:00 committed by Hiroshi SHIBATA
parent 912f1cda0d
commit 4a042b2255

View File

@ -93,9 +93,7 @@ module OpenSSL::Buffering
nil
else
size = @rbuffer.size unless size
ret = @rbuffer[0, size]
@rbuffer[0, size] = ""
ret
@rbuffer.slice!(0, size)
end
end
@ -106,8 +104,7 @@ module OpenSSL::Buffering
#
# Get the next 8bit byte from `ssl`. Returns `nil` on EOF
def getbyte
byte = read(1)
byte && byte.unpack1("C")
read(1)&.ord
end
##