Skip to content

Commit 02e44b1

Browse files
authored
Merge pull request #188 from eregon/improve-condition
Improve condition for whether force_encoding is needed
2 parents 1faa48a + 5d08297 commit 02e44b1

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)