diff options
author | Mau Magnaguagno <[email protected]> | 2022-12-26 08:35:54 -0300 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-09-06 19:24:02 +0900 |
commit | 4a042b2255519eb3e2826609dd8c042e164e7a26 (patch) | |
tree | 61114053bb02c6b527e73a995f5aba253c89b86e /ext | |
parent | 912f1cda0d2ddfb4e6a52d43952a0562cb0fb46d (diff) |
[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
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/lib/openssl/buffering.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb index d47e1082ef..9570f14f37 100644 --- a/ext/openssl/lib/openssl/buffering.rb +++ b/ext/openssl/lib/openssl/buffering.rb @@ -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 ## |