Skip to content

Commit

Permalink
Switch from RubyArray addAll to concat method to preserve the encodin…
Browse files Browse the repository at this point in the history
…g and avoid implicit deconding in addAll iterator
  • Loading branch information
andsel committed Jan 28, 2025
1 parent 3a090a0 commit 69bd4f4
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ public RubyArray extract(final ThreadContext context, IRubyObject data) {
final RubyArray entities = data.convertToString().split(delimiter, -1);
if (!bufferFullErrorNotified) {
input.clear();
input.addAll(entities);
input.concat(entities);
} else {
// after a full buffer signal
if (input.isEmpty()) {
// after a buffer full error, the remaining part of the line, till next delimiter,
// has to be consumed, unless the input buffer doesn't still contain fragments of
// subsequent tokens.
entities.shift(context);
input.addAll(entities);
input.concat(entities);
} else {
// merge last of the input with first of incoming data segment
if (!entities.isEmpty()) {
RubyString last = ((RubyString) input.pop(context));
RubyString nextFirst = ((RubyString) entities.shift(context));
entities.unshift(last.concat(nextFirst));
input.addAll(entities);
input.concat(entities);
}
}
}
Expand Down

0 comments on commit 69bd4f4

Please sign in to comment.