Skip to content

Commit

Permalink
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions truffle/src/main/java/org/jruby/truffle/core/StringNodes.java
Original file line number Diff line number Diff line change
@@ -2200,12 +2200,10 @@ public DynamicObject reverse(DynamicObject string) {
final int end = p + len;
int op = len;
final byte[] reversedBytes = new byte[len];
boolean single = true;

while (p < end) {
int cl = StringSupport.length(enc, originalBytes, p, end);
if (cl > 1 || (originalBytes[p] & 0x80) != 0) {
single = false;
op -= cl;
System.arraycopy(originalBytes, p, reversedBytes, op, cl);
p += cl;
@@ -2214,13 +2212,7 @@ public DynamicObject reverse(DynamicObject string) {
}
}

// TODO (nirvdrum 09-Jan-16): If we guarantee no strings can have an unknown code range, this check can be removed.
CodeRange codeRange = rope.getCodeRange();
if (codeRange == CodeRange.CR_UNKNOWN) {
codeRange = single ? CodeRange.CR_7BIT : CodeRange.CR_VALID;
}

StringOperations.setRope(string, makeLeafRopeNode.executeMake(reversedBytes, rope.getEncoding(), codeRange));
StringOperations.setRope(string, makeLeafRopeNode.executeMake(reversedBytes, rope.getEncoding(), rope.getCodeRange()));

return string;
}

0 comments on commit 50adf1c

Please sign in to comment.