Skip to content

Commit 9f11cbb

Browse files
committed
Increment position before yielding
Enumerator methods like #take will bail out before returning normally from the yield, avoiding the position increment.
1 parent 5643a3b commit 9f11cbb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/java/org/jruby/ext/stringio/StringIO.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,11 @@ public IRubyObject each_codepoint(ThreadContext context, Block block) {
12861286

12871287
int c = StringSupport.codePoint(runtime, enc, stringBytes, begin + ptr.pos, stringBytes.length);
12881288
int n = StringSupport.codeLength(enc, c);
1289-
block.yield(context, runtime.newFixnum(c));
1289+
1290+
// increment before yield
12901291
ptr.pos += n;
1292+
1293+
block.yield(context, runtime.newFixnum(c));
12911294
}
12921295
}
12931296
}

0 commit comments

Comments
 (0)