Skip to content

Commit 9400427

Browse files
committed
Use an uncached node rather than a manual slow path copy
1 parent a70bc8c commit 9400427

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,26 +1091,6 @@ protected Rope withEncodingAsciiCompatible(ManagedRope rope, Encoding encoding,
10911091
}
10921092
}
10931093

1094-
// Version without a node
1095-
@TruffleBoundary
1096-
public static Rope withEncodingSlow(Rope originalRope, Encoding newEncoding) {
1097-
if (originalRope.getEncoding() == newEncoding) {
1098-
return originalRope;
1099-
}
1100-
1101-
if (originalRope.getCodeRange() == CR_7BIT && newEncoding.isAsciiCompatible()) {
1102-
return originalRope.withEncoding(newEncoding, CR_7BIT);
1103-
}
1104-
1105-
if (newEncoding == ASCIIEncoding.INSTANCE && originalRope.getCodeRange() == CR_VALID &&
1106-
originalRope.getEncoding().isAsciiCompatible()) {
1107-
// ASCII-compatible CR_VALID strings are also CR_VALID in binary.
1108-
return originalRope.withEncoding(newEncoding, CR_VALID);
1109-
}
1110-
1111-
return RopeOperations.create(originalRope.getBytes(), newEncoding, CR_UNKNOWN);
1112-
}
1113-
11141094
private Rope rescanBytesForEncoding(Rope rope, Encoding encoding, BytesNode bytesNode,
11151095
MakeLeafRopeNode makeLeafRopeNode) {
11161096
return makeLeafRopeNode.executeMake(bytesNode.execute(rope), encoding, CR_UNKNOWN, NotProvided.INSTANCE);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.truffleruby.core.Hashing;
4141
import org.truffleruby.core.encoding.EncodingManager;
4242
import org.truffleruby.core.rope.RopeNodes.WithEncodingNode;
43+
import org.truffleruby.core.rope.RopeNodesFactory.WithEncodingNodeGen;
4344
import org.truffleruby.core.string.StringAttributes;
4445
import org.truffleruby.core.string.StringOperations;
4546
import org.truffleruby.core.string.StringSupport;
@@ -132,7 +133,7 @@ public static Rope emptyRope(Encoding encoding) {
132133
}
133134

134135
public static Rope withEncoding(Rope originalRope, Encoding newEncoding) {
135-
return WithEncodingNode.withEncodingSlow(originalRope, newEncoding);
136+
return WithEncodingNodeGen.getUncached().executeWithEncoding(originalRope, newEncoding);
136137
}
137138

138139
public static Rope encodeAscii(String value, Encoding encoding) {

0 commit comments

Comments
 (0)