Skip to content

Commit 0da6538

Browse files
committed
DeleteBangStringsNode and CountStringsNode are simplified
1 parent a3a35ee commit 0da6538

File tree

1 file changed

+9
-31
lines changed

1 file changed

+9
-31
lines changed

src/main/java/org/truffleruby/core/string/StringHelperNodes.java

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -164,27 +164,16 @@ protected boolean notComparable(
164164
}
165165

166166
@ImportStatic(StringGuards.class)
167-
public abstract static class StringCountStringsNode extends CoreMethodArrayArgumentsNode {
167+
public abstract static class CountStringsNode extends TrTableNode {
168168

169+
public abstract int execute(Object string, TStringWithEncoding[] tstringsWithEncs);
169170

170171
@Specialization(guards = "libString.getTString(string).isEmpty()", limit = "1")
171-
protected int count(Object string, Object[] args,
172-
@Cached RubyStringLibrary libString) {
172+
protected int count(Object string, TStringWithEncoding[] args,
173+
@Cached @Shared RubyStringLibrary libString) {
173174
return 0;
174175
}
175176

176-
@Specialization
177-
protected int countStrings(Object string, TStringWithEncoding[] args,
178-
@Cached CountStringsNode countStringsNode) {
179-
return countStringsNode.execute(string, args);
180-
}
181-
}
182-
183-
@ImportStatic(StringGuards.class)
184-
public abstract static class CountStringsNode extends TrTableNode {
185-
186-
public abstract int execute(Object string, TStringWithEncoding[] tstringsWithEncs);
187-
188177
@Specialization(
189178
guards = {
190179
"cachedArgs.length > 0",
@@ -299,22 +288,6 @@ protected boolean argsMatch(TStringWithEncoding[] cachedStrings, TStringWithEnco
299288
}
300289
}
301290

302-
@ImportStatic(StringGuards.class)
303-
public abstract static class StringDeleteBangStringsNode extends CoreMethodArrayArgumentsNode {
304-
305-
@Specialization(guards = "string.tstring.isEmpty()")
306-
protected Object deleteBangEmpty(RubyString string, Object[] args) {
307-
return nil;
308-
}
309-
310-
@Specialization
311-
protected static Object deleteBangString(RubyString string, TStringWithEncoding[] args,
312-
@Cached DeleteBangStringsNode deleteBangStringsNode,
313-
@Bind("this") Node node) {
314-
return deleteBangStringsNode.execute(node, string, args);
315-
}
316-
}
317-
318291

319292
@ImportStatic(StringGuards.class)
320293
@GenerateCached(false)
@@ -323,6 +296,11 @@ public abstract static class DeleteBangStringsNode extends TrTableNode {
323296

324297
public abstract Object execute(Node node, RubyString string, TStringWithEncoding[] tstringsWithEncs);
325298

299+
@Specialization(guards = "string.tstring.isEmpty()")
300+
protected Object deleteBangEmpty(RubyString string, TStringWithEncoding[] args) {
301+
return nil;
302+
}
303+
326304
@Specialization(
327305
guards = {
328306
"cachedArgs.length > 0",

0 commit comments

Comments
 (0)