Ignore:
Timestamp:
Jul 28, 2011, 10:32:40 AM (14 years ago)
Author:
[email protected]
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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.