Skip to content

Commit

Permalink
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
Original file line number Diff line number Diff line change
@@ -695,7 +695,6 @@ public ChopBangNode(RubyContext context, SourceSection sourceSection) {
sizeNode = StringNodesFactory.SizeNodeFactory.create(context, sourceSection, new RubyNode[] { null });
}

@TruffleBoundary
@Specialization
public Object chopBang(VirtualFrame frame, RubyString string) {
if (sizeNode.executeInteger(frame, string) == 0) {
@@ -730,27 +729,27 @@ public CountNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public int count(VirtualFrame frame, RubyString string, Object[] otherStrings) {
public int count(VirtualFrame frame, RubyString string, Object[] args) {
if (string.getByteList().getRealSize() == 0) {
return 0;
}

if (otherStrings.length == 0) {
if (args.length == 0) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentErrorEmptyVarargs(this));
}

return countSlow(frame, string, otherStrings);
}

@TruffleBoundary
private int countSlow(VirtualFrame frame, RubyString string, Object[] args) {
RubyString[] otherStrings = new RubyString[args.length];

for (int i = 0; i < args.length; i++) {
otherStrings[i] = toStr.executeRubyString(frame, args[i]);
}

return countSlow(string, otherStrings);
}

@TruffleBoundary
private int countSlow(RubyString string, RubyString[] otherStrings) {
RubyString otherStr = otherStrings[0];
Encoding enc = otherStr.getByteList().getEncoding();

@@ -851,27 +850,27 @@ public DeleteBangNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object deleteBang(VirtualFrame frame, RubyString string, Object... otherStrings) {
public Object deleteBang(VirtualFrame frame, RubyString string, Object... args) {
if (string.getByteList().length() == 0) {
return nil();
}

if (otherStrings.length == 0) {
if (args.length == 0) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentErrorEmptyVarargs(this));
}

return deleteBangSlow(frame, string, otherStrings);
}

@TruffleBoundary
private Object deleteBangSlow(VirtualFrame frame, RubyString string, Object... args) {
RubyString[] otherStrings = new RubyString[args.length];

for (int i = 0; i < args.length; i++) {
otherStrings[i] = toStr.executeRubyString(frame, args[i]);
}

return deleteBangSlow(string, otherStrings);
}

@TruffleBoundary
private Object deleteBangSlow(RubyString string, RubyString... otherStrings) {
RubyString otherString = otherStrings[0];
Encoding enc = string.checkEncoding(otherString, this);

0 comments on commit be387a9

Please sign in to comment.