Skip to content

Commit 51ae78b

Browse files
committed
Cleanup QuoteNode
1 parent b5be3b4 commit 51ae78b

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/main/java/org/truffleruby/core/regexp/RegexpNodes.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.truffleruby.language.control.RaiseException;
3838
import org.truffleruby.language.library.RubyStringLibrary;
3939

40-
import com.oracle.truffle.api.CompilerDirectives;
4140
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
4241
import com.oracle.truffle.api.dsl.Cached;
4342
import com.oracle.truffle.api.dsl.Cached.Shared;
@@ -59,8 +58,6 @@ int hash(RubyRegexp regexp) {
5958
@CoreMethod(names = { "quote", "escape" }, onSingleton = true, required = 1)
6059
public abstract static class QuoteNode extends CoreMethodArrayArgumentsNode {
6160

62-
@Child private QuoteNode quoteNode;
63-
6461
public abstract RubyString execute(Object raw);
6562

6663
public static QuoteNode create() {
@@ -75,22 +72,16 @@ RubyString quoteString(Object raw,
7572

7673
@Specialization
7774
RubyString quoteSymbol(RubySymbol raw) {
78-
return doQuoteString(createString(raw.tstring, raw.encoding));
75+
return createString(ClassicRegexp.quote19(new ATStringWithEncoding(raw.tstring, raw.encoding)));
7976
}
8077

8178
@Fallback
8279
RubyString quote(Object raw,
83-
@Cached ToStrNode toStrNode) {
84-
return doQuoteString(toStrNode.execute(this, raw));
80+
@Cached ToStrNode toStrNode,
81+
@Cached QuoteNode recursive) {
82+
return recursive.execute(toStrNode.execute(this, raw));
8583
}
8684

87-
private RubyString doQuoteString(Object raw) {
88-
if (quoteNode == null) {
89-
CompilerDirectives.transferToInterpreterAndInvalidate();
90-
quoteNode = insert(QuoteNode.create());
91-
}
92-
return quoteNode.execute(raw);
93-
}
9485
}
9586

9687
@CoreMethod(names = "source")

0 commit comments

Comments
 (0)