Skip to content

Commit 5d08297

Browse files
committed
Improve condition for whether force_encoding is needed
* oracle/truffleruby#3506 was fixed, instead of hardcoding Ruby engines and versions, it seems better to do the check whether the force_encoding is needed.
1 parent 1faa48a commit 5d08297

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/redis_client/ruby_connection/buffered_io.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,6 @@ def ensure_remaining(bytes)
147147
end
148148
end
149149

150-
RESET_BUFFER_ENCODING = RUBY_ENGINE == "truffleruby"
151-
private_constant :RESET_BUFFER_ENCODING
152-
153150
def fill_buffer(strict, size = @chunk_size)
154151
remaining = size
155152
start = @offset - @buffer.bytesize
@@ -174,7 +171,7 @@ def fill_buffer(strict, size = @chunk_size)
174171
if empty_buffer
175172
@offset = start
176173
empty_buffer = false
177-
@buffer.force_encoding(Encoding::UTF_8) if RESET_BUFFER_ENCODING
174+
@buffer.force_encoding(Encoding::UTF_8) unless @buffer.encoding == Encoding::UTF_8
178175
else
179176
@buffer << bytes.force_encoding(Encoding::UTF_8)
180177
end

0 commit comments

Comments
 (0)