Skip to content

Commit 177f786

Browse files
committed
[GR-19220] LazyIntRope specialization for string_to_inum primitive (#2401)
PullRequest: truffleruby/2802
2 parents 2a94986 + 8851fc6 commit 177f786

File tree

4 files changed

+104
-99
lines changed

4 files changed

+104
-99
lines changed

src/main/java/org/truffleruby/core/exception/CoreExceptions.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
import org.truffleruby.core.proc.RubyProc;
3232
import org.truffleruby.core.range.RubyIntRange;
3333
import org.truffleruby.core.rope.Rope;
34+
import org.truffleruby.core.rope.RopeOperations;
3435
import org.truffleruby.core.string.CoreStrings;
3536
import org.truffleruby.core.string.RubyString;
3637
import org.truffleruby.core.string.StringOperations;
3738
import org.truffleruby.core.string.StringUtils;
3839
import org.truffleruby.core.symbol.RubySymbol;
3940
import org.truffleruby.core.thread.ThreadNodes.ThreadGetExceptionNode;
40-
import org.truffleruby.core.string.ImmutableRubyString;
4141
import org.truffleruby.language.Nil;
4242
import org.truffleruby.language.backtrace.Backtrace;
4343
import org.truffleruby.language.backtrace.BacktraceFormatter;
@@ -237,12 +237,8 @@ public RubyException argumentErrorWrongArgumentType(Object object, String expect
237237
}
238238

239239
@TruffleBoundary
240-
public RubyException argumentErrorInvalidStringToInteger(Object object, Node currentNode) {
241-
assert object instanceof RubyString || object instanceof ImmutableRubyString;
242-
// TODO (nirvdrum 19-Apr-18): Guard against String#inspect being redefined to return something other than a String.
243-
final String formattedObject = RubyStringLibrary
244-
.getUncached()
245-
.getJavaString(RubyContext.send(object, "inspect"));
240+
public RubyException argumentErrorInvalidStringToInteger(Rope rope, Node currentNode) {
241+
final String formattedObject = RopeOperations.decodeRope(rope);
246242
return argumentError(StringUtils.format("invalid value for Integer(): %s", formattedObject), currentNode);
247243
}
248244

0 commit comments

Comments
 (0)