Skip to content

Commit 4cac101

Browse files
committed
Remove Strings.fromNumber.
1 parent ac77cd3 commit 4cac101

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/JSRuntime.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,9 +1566,20 @@ public static boolean isHex(char c) {
15661566

15671567
@TruffleBoundary
15681568
public static long parseArrayIndexIsIndexRaw(Object o) {
1569-
assert isArrayIndex(o);
1570-
assert Strings.isTString(o) || o instanceof Number;
1571-
return parseArrayIndexRaw(o instanceof TruffleString str ? str : Strings.fromNumber((Number) o), TruffleString.ReadCharUTF16Node.getUncached());
1569+
assert (Strings.isTString(o) || o instanceof Number) && isArrayIndex(o) : o;
1570+
TruffleString asStr;
1571+
if (o instanceof TruffleString str) {
1572+
asStr = str;
1573+
} else if (o instanceof Integer i) {
1574+
return i;
1575+
} else if (o instanceof Long l) {
1576+
return l;
1577+
} else if (o instanceof Double d) {
1578+
asStr = doubleToString(d);
1579+
} else {
1580+
throw CompilerDirectives.shouldNotReachHere();
1581+
}
1582+
return parseArrayIndexRaw(asStr, TruffleString.ReadCharUTF16Node.getUncached());
15721583
}
15731584

15741585
/**

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/Strings.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import java.util.ArrayList;
4545
import java.util.Locale;
4646

47-
import com.oracle.truffle.api.CompilerDirectives;
4847
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
4948
import com.oracle.truffle.api.interop.InteropLibrary;
5049
import com.oracle.truffle.api.interop.UnsupportedMessageException;
@@ -848,28 +847,6 @@ public static TruffleString fromInt(int intValue) {
848847
return fromLong(intValue);
849848
}
850849

851-
public static TruffleString fromDouble(double d) {
852-
return TruffleString.FromJavaStringNode.getUncached().execute(doubleToJavaString(d), TruffleString.Encoding.UTF_16);
853-
}
854-
855-
@TruffleBoundary
856-
private static String doubleToJavaString(double d) {
857-
return String.valueOf(d);
858-
}
859-
860-
public static TruffleString fromNumber(Number number) {
861-
if (number instanceof Integer) {
862-
return fromInt(number.intValue());
863-
}
864-
if (number instanceof Long) {
865-
return fromLong(number.longValue());
866-
}
867-
if (number instanceof Double) {
868-
return fromDouble(number.doubleValue());
869-
}
870-
throw CompilerDirectives.shouldNotReachHere();
871-
}
872-
873850
@TruffleBoundary
874851
public static TruffleString fromBigInt(BigInt bi) {
875852
return fromBigInt(TruffleString.FromJavaStringNode.getUncached(), bi);

0 commit comments

Comments
 (0)