Changeset 37048 in webkit
- Timestamp:
- Sep 28, 2008, 7:00:42 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r37040 r37048 1 2008-09-28 Mark Rowe <mrowe@apple.com> 2 3 Reviewed by Cameron Zwarich. 4 5 Speed up parseInt and parseFloat. 6 7 Repeatedly indexing into a UString is slow, so retrieve a pointer into the underlying buffer once up front 8 and use that instead. This is a 7% win on a parseInt/parseFloat micro-benchmark. 9 10 * kjs/JSGlobalObjectFunctions.cpp: 11 (JSC::parseInt): 12 (JSC::parseFloat): 13 1 14 2008-09-28 Simon Hausmann <hausmann@webkit.org> 2 15 -
trunk/JavaScriptCore/kjs/JSGlobalObjectFunctions.cpp
r36434 r37048 196 196 { 197 197 int length = s.size(); 198 const UChar* data = s.data(); 198 199 int p = 0; 199 200 200 while (p < length && isStrWhiteSpace( s[p]))201 while (p < length && isStrWhiteSpace(data[p])) 201 202 ++p; 202 203 203 204 double sign = 1; 204 205 if (p < length) { 205 if ( s[p] == '+')206 if (data[p] == '+') 206 207 ++p; 207 else if ( s[p] == '-') {208 else if (data[p] == '-') { 208 209 sign = -1; 209 210 ++p; … … 211 212 } 212 213 213 if ((radix == 0 || radix == 16) && length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) {214 if ((radix == 0 || radix == 16) && length - p >= 2 && data[p] == '0' && (data[p + 1] == 'x' || data[p + 1] == 'X')) { 214 215 radix = 16; 215 216 p += 2; 216 217 } else if (radix == 0) { 217 if (p < length && s[p] == '0')218 if (p < length && data[p] == '0') 218 219 radix = 8; 219 220 else … … 228 229 double number = 0; 229 230 while (p < length) { 230 int digit = parseDigit( s[p], radix);231 int digit = parseDigit(data[p], radix); 231 232 if (digit == -1) 232 233 break; … … 255 256 // Need to skip any whitespace and then one + or - sign. 256 257 int length = s.size(); 258 const UChar* data = s.data(); 257 259 int p = 0; 258 while (p < length && isStrWhiteSpace( s[p]))260 while (p < length && isStrWhiteSpace(data[p])) 259 261 ++p; 260 262 261 if (p < length && ( s[p] == '+' || s[p] == '-'))263 if (p < length && (data[p] == '+' || data[p] == '-')) 262 264 ++p; 263 265 264 if (length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X'))266 if (length - p >= 2 && data[p] == '0' && (data[p + 1] == 'x' || data[p + 1] == 'X')) 265 267 return 0; 266 268
Note:
See TracChangeset
for help on using the changeset viewer.