Changeset 91938 in webkit


Ignore:
Timestamp:
Jul 28, 2011 10:32:40 AM (13 years ago)
Author:
barraclough@apple.com
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.
Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r91933 r91938  
     12011-07-28  Gavin Barraclough  <barraclough@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=65325
     4        Performance tweak to parseInt
     5
     6        Reviewed by Oliver Hunt.
     7
     8        * runtime/JSGlobalObjectFunctions.cpp:
     9        (JSC::globalFuncParseInt):
     10            - parseInt applied to small positive numbers = floor.
     11
    1122011-07-28  Dan Bernstein  <mitz@apple.com>
    213
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r89219 r91938  
    461461{
    462462    JSValue value = exec->argument(0);
     463
     464    // Optimized case: If the argument is a positive number in the integer
     465    // range, and the exponent is 10, then parseInt is equivalent to floor.
     466    double n;
     467    if (value.getNumber(n) && n >= 0 && n < INT_MAX && exec->argument(1).isUndefined())
     468        return JSValue::encode(jsNumber(static_cast<int>(n)));
     469
    463470    int32_t radix = exec->argument(1).toInt32(exec);
    464471
Note: See TracChangeset for help on using the changeset viewer.