Skip to content

Commit 0448794

Browse files
committed
Adopt making interpolating String/Symbol/Regexp's parts frozen
1 parent 3d15c85 commit 0448794

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/main/java/org/truffleruby/parser/YARPTranslator.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ public RubyNode visitInterpolatedSymbolNode(Nodes.InterpolatedSymbolNode node) {
24602460
public RubyNode visitInterpolatedXStringNode(Nodes.InterpolatedXStringNode node) {
24612461
// replace `` literal with a Kernel#` method call
24622462

2463-
var stringNode = new Nodes.InterpolatedStringNode(node.parts, node.startOffset, node.length);
2463+
var stringNode = new Nodes.InterpolatedStringNode(NO_FLAGS, node.parts, node.startOffset, node.length);
24642464
final RubyNode string = stringNode.accept(this);
24652465

24662466
final RubyNode rubyNode = createCallNode(new SelfNode(), "`", string);
@@ -2518,15 +2518,7 @@ private ToSNode[] translateInterpolatedParts(Nodes.Node[] parts) {
25182518
final ToSNode[] children = new ToSNode[parts.length];
25192519

25202520
for (int i = 0; i < parts.length; i++) {
2521-
final RubyNode expression;
2522-
2523-
if (parts[i] instanceof Nodes.StringNode stringNode) {
2524-
// use frozen String literals to avoid extra allocations in the interpreter
2525-
// it will be addressed in Prism (see https://github.com/ruby/prism/issues/2532)
2526-
expression = visitStringNode(stringNode, true);
2527-
} else {
2528-
expression = parts[i].accept(this);
2529-
}
2521+
RubyNode expression = parts[i].accept(this);
25302522
children[i] = ToSNodeGen.create(expression);
25312523
}
25322524

@@ -3260,10 +3252,6 @@ public RubyNode visitStatementsNode(Nodes.StatementsNode node) {
32603252

32613253
@Override
32623254
public RubyNode visitStringNode(Nodes.StringNode node) {
3263-
return visitStringNode(node, node.isFrozen());
3264-
}
3265-
3266-
public RubyNode visitStringNode(Nodes.StringNode node, boolean frozen) {
32673255
final RubyNode rubyNode;
32683256
final RubyEncoding encoding;
32693257

@@ -3277,7 +3265,7 @@ public RubyNode visitStringNode(Nodes.StringNode node, boolean frozen) {
32773265

32783266
byte[] bytes = node.unescaped;
32793267

3280-
if (!frozen) {
3268+
if (!node.isFrozen()) {
32813269
final TruffleString cachedTString = language.tstringCache.getTString(bytes, encoding);
32823270
rubyNode = new StringLiteralNode(cachedTString, encoding);
32833271
} else {

0 commit comments

Comments
 (0)