Changeset 4639 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp


Ignore:
Timestamp:
Jul 13, 2003, 2:40:45 PM (22 years ago)
Author:
darin
Message:

Reviewed by Maciej.

  • do some improvements Maciej suggested while reviewing the array index change
  • kjs/array_object.cpp: (getArrayIndex): Return a flag to say whether the index was value separately, to avoid in-band signalling. (ArrayInstanceImp::get): Update for new getArrayIndex parameters. (ArrayInstanceImp::put): Ditto. (ArrayInstanceImp::hasProperty): Ditto. (ArrayInstanceImp::setLength): Ditto.
  • kjs/ustring.cpp: (UString::toStrictUInt32): Check for overflow in a way that avoids doing a divide every time through the loop. But note that it adds an extra branch to the loop. I wonder which is worse.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r4630 r4639  
    686686    const unsigned d = c - '0';
    687687   
    688     // Check for overflow.
    689     const unsigned maxProduct = 0xFFFFFFFFU - d;
    690     if (i > maxProduct / 10)
     688    // Multiply by 10, checking for overflow out of 32 bits.
     689    if (i > 0xFFFFFFFFU / 10)
    691690      return 0;
     691    i *= 10;
    692692   
    693     // Add in another digit.
    694     i *= 10;
     693    // Add in the digit, checking for overflow out of 32 bits.
     694    const unsigned max = 0xFFFFFFFFU - d;
     695    if (i > max)
     696        return 0;
    695697    i += d;
    696698   
Note: See TracChangeset for help on using the changeset viewer.