Skip to content

Commit 9a843bc

Browse files
committed
Use a rope's 'actual' encoding when getting searching for a codepoint.
1 parent ddc6179 commit 9a843bc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/java/org/truffleruby/core/rope/RopeNodes.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,16 +1205,15 @@ public int getCodePointMultiByte(Rope rope, int index,
12051205
@Cached("create()") EncodingNodes.GetActualEncodingNode getActualEncodingNode) {
12061206
final byte[] bytes = bytesNode.execute(rope);
12071207
final Encoding encoding = rope.getEncoding();
1208+
final Encoding actualEncoding = getActualEncodingNode.execute(rope);
12081209
final CodeRange codeRange = codeRangeNode.execute(rope);
12091210

1210-
final int characterLength = characterLength(encoding, codeRange, bytes, index, rope.byteLength());
1211+
final int characterLength = characterLength(actualEncoding, codeRange, bytes, index, rope.byteLength());
12111212
if (characterLength <= 0) {
12121213
errorProfile.enter();
12131214
throw new RaiseException(getContext(), getContext().getCoreExceptions().argumentError("invalid byte sequence in " + encoding, null));
12141215
}
12151216

1216-
final Encoding actualEncoding = getActualEncodingNode.execute(rope);
1217-
12181217
return mbcToCode(actualEncoding, bytes, index, rope.byteLength());
12191218
}
12201219

0 commit comments

Comments
 (0)