Title: [91938] trunk/Source/_javascript_Core
- Revision
- 91938
- Author
- barraclo...@apple.com
- Date
- 2011-07-28 10:32:40 -0700 (Thu, 28 Jul 2011)
Log Message
https://bugs.webkit.org/show_bug.cgi?id=65325
Performance tweak to parseInt
Reviewed by Oliver Hunt.
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncParseInt):
- parseInt applied to small positive numbers = floor.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (91937 => 91938)
--- trunk/Source/_javascript_Core/ChangeLog 2011-07-28 17:24:47 UTC (rev 91937)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-07-28 17:32:40 UTC (rev 91938)
@@ -1,3 +1,14 @@
+2011-07-28 Gavin Barraclough <barraclo...@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=65325
+ Performance tweak to parseInt
+
+ Reviewed by Oliver Hunt.
+
+ * runtime/JSGlobalObjectFunctions.cpp:
+ (JSC::globalFuncParseInt):
+ - parseInt applied to small positive numbers = floor.
+
2011-07-28 Dan Bernstein <m...@apple.com>
Build fix.
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (91937 => 91938)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2011-07-28 17:24:47 UTC (rev 91937)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2011-07-28 17:32:40 UTC (rev 91938)
@@ -460,6 +460,13 @@
EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)
{
JSValue value = exec->argument(0);
+
+ // Optimized case: If the argument is a positive number in the integer
+ // range, and the exponent is 10, then parseInt is equivalent to floor.
+ double n;
+ if (value.getNumber(n) && n >= 0 && n < INT_MAX && exec->argument(1).isUndefined())
+ return JSValue::encode(jsNumber(static_cast<int>(n)));
+
int32_t radix = exec->argument(1).toInt32(exec);
if (radix != 0 && radix != 10)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes