Skip to content

Commit b708b61

Browse files
Merge pull request #1103 from byroot/skip-repeated-jruby-checks
Avoid repeatedly checking `RUBY_ENGINE`
2 parents 988f611 + d0f5879 commit b708b61

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

lib/dalli/protocol/connection_manager.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,20 @@ def read_line
155155
error_on_request!(e)
156156
end
157157

158-
def read(count)
159-
# JRuby doesn't support IO#timeout=, so use custom readfull implementation
160-
# CRuby 3.3+ has IO#timeout= which makes IO#read work with timeouts
161-
if RUBY_ENGINE == 'jruby'
158+
# JRuby doesn't support IO#timeout=, so use custom readfull implementation
159+
# CRuby 3.3+ has IO#timeout= which makes IO#read work with timeouts
160+
if RUBY_ENGINE == 'jruby'
161+
def read(count)
162162
@sock.readfull(count)
163-
else
163+
rescue SystemCallError, *TIMEOUT_ERRORS, *SSL_ERRORS, EOFError => e
164+
error_on_request!(e)
165+
end
166+
else
167+
def read(count)
164168
@sock.read(count)
169+
rescue SystemCallError, *TIMEOUT_ERRORS, *SSL_ERRORS, EOFError => e
170+
error_on_request!(e)
165171
end
166-
rescue SystemCallError, *TIMEOUT_ERRORS, *SSL_ERRORS, EOFError => e
167-
error_on_request!(e)
168172
end
169173

170174
def write(bytes)

0 commit comments

Comments
 (0)