Skip to content

Commit c160244

Browse files
committed
Small code tidy up.
1 parent d49cf63 commit c160244

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

src/main/java/org/truffleruby/core/numeric/FloatNodes.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -874,57 +874,47 @@ protected RubyString toSNaN(double value,
874874

875875
@Specialization(guards = "hasNoExp(value)")
876876
protected RubyString toSNoExp(double value) {
877-
return makeStringNode.executeMake(makeRopeNoExp(value), Encodings.US_ASCII, NotProvided.INSTANCE);
877+
return makeStringNode.executeMake(makeRopeNoExp(value), Encodings.US_ASCII, CodeRange.CR_7BIT);
878878
}
879879

880880
@Specialization(guards = "hasLargeExp(value)")
881881
protected RubyString toSLargeExp(double value) {
882-
return makeStringNode.executeMake(makeRopeLargeExp(value), Encodings.US_ASCII, NotProvided.INSTANCE);
882+
return makeStringNode.executeMake(makeRopeLargeExp(value), Encodings.US_ASCII, CodeRange.CR_7BIT);
883883
}
884884

885885
@Specialization(guards = "hasSmallExp(value)")
886886
protected RubyString toSSmallExp(double value) {
887-
return makeStringNode.executeMake(makeRopeSmallExp(value), Encodings.US_ASCII, NotProvided.INSTANCE);
887+
return makeStringNode.executeMake(makeRopeSmallExp(value), Encodings.US_ASCII, CodeRange.CR_7BIT);
888888
}
889889

890890
@TruffleBoundary
891-
private Rope makeRopeSimple(double value) {
892-
String str = Double.toString(value);
893-
894-
return RopeOperations.encodeAscii(str, Encodings.US_ASCII.jcoding);
895-
}
896-
897-
@TruffleBoundary
898-
private Rope makeRopeNoExp(double value) {
899-
String str = DF_NO_EXP.format(value);
900-
return RopeOperations.encodeAscii(str, Encodings.US_ASCII.jcoding);
891+
private String makeRopeNoExp(double value) {
892+
return DF_NO_EXP.format(value);
901893
}
902894

903895
@TruffleBoundary
904-
private Rope makeRopeSmallExp(double value) {
905-
String str = DF_SMALL_EXP.format(value);
906-
return RopeOperations.encodeAscii(str, Encodings.US_ASCII.jcoding);
896+
private String makeRopeSmallExp(double value) {
897+
return DF_SMALL_EXP.format(value);
907898
}
908899

909900
@TruffleBoundary
910-
private Rope makeRopeLargeExp(double value) {
911-
String str = DF_LARGE_EXP.format(value);
912-
return RopeOperations.encodeAscii(str, Encodings.US_ASCII.jcoding);
901+
private String makeRopeLargeExp(double value) {
902+
return DF_LARGE_EXP.format(value);
913903
}
914904

915905
protected static boolean hasNoExp(double value) {
916906
double abs = Math.abs(value);
917-
return abs == 0.0d || ((abs >= 0.0001d) && (abs < 1_000_000_000_000_000.0d));
907+
return abs == 0.0 || ((abs >= 0.0001) && (abs < 1_000_000_000_000_000.0));
918908
}
919909

920910
protected static boolean hasLargeExp(double value) {
921911
double abs = Math.abs(value);
922-
return (abs >= 1_000_000_000_000_000.0d);
912+
return (abs >= 1_000_000_000_000_000.0);
923913
}
924914

925915
protected static boolean hasSmallExp(double value) {
926916
double abs = Math.abs(value);
927-
return (abs < 0.0001d) && (abs != 0.0d);
917+
return (abs < 0.0001) && (abs != 0.0);
928918
}
929919

930920
protected static Rope specialValueRope(double value) {

0 commit comments

Comments
 (0)