Sfoglia il codice sorgente

Optimizing string conversion for integer values

Sebastien Ros 9 anni fa
parent
commit
97e10ace08
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  1. 6 0
      Jint/Native/Number/NumberPrototype.cs

+ 6 - 0
Jint/Native/Number/NumberPrototype.cs

@@ -281,6 +281,12 @@ namespace Jint.Native.Number
                 return "-" + ToNumberString(-m);
             }
 
+            var l = (long)m;
+            if(l == m)
+            {
+                return l.ToString(CultureInfo.InvariantCulture);
+            }
+
             // V8 FastDtoa can't convert all numbers, so try it first but
             // fall back to old DToA in case it fails
             var result = FastDtoa.NumberToString(m);