Changeset 65468 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Aug 16, 2010, 4:31:33 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSString.cpp
r65177 r65468 109 109 { 110 110 if (!isRope()) { 111 unsignedmatchPosition = m_value.find(character);112 if (matchPosition == UString::NotFound)111 size_t matchPosition = m_value.find(character); 112 if (matchPosition == notFound) 113 113 return JSValue(this); 114 114 return jsString(exec, m_value.substr(0, matchPosition), replacement, m_value.substr(matchPosition + 1)); … … 120 120 size_t fiberCount = 0; 121 121 StringImpl* matchString = 0; 122 int matchPosition = -1;122 size_t matchPosition = notFound; 123 123 for (RopeIterator it(m_other.m_fibers.data(), m_fiberCount); it != end; ++it) { 124 124 ++fiberCount; … … 128 128 StringImpl* string = *it; 129 129 matchPosition = string->find(character); 130 if (matchPosition == -1)130 if (matchPosition == notFound) 131 131 continue; 132 132 matchString = string; -
trunk/JavaScriptCore/runtime/RegExp.cpp
r65188 r65468 57 57 // String::match and RegExpObject::match. 58 58 if (!flags.isNull()) { 59 if (flags.find('g') != UString::NotFound)59 if (flags.find('g') != notFound) 60 60 m_flagBits |= Global; 61 if (flags.find('i') != UString::NotFound)61 if (flags.find('i') != notFound) 62 62 m_flagBits |= IgnoreCase; 63 if (flags.find('m') != UString::NotFound)63 if (flags.find('m') != notFound) 64 64 m_flagBits |= Multiline; 65 65 } -
trunk/JavaScriptCore/runtime/RegExpKey.h
r65286 r65468 74 74 { 75 75 flagsValue = 0; 76 if (flags.find('g') != UString::NotFound)76 if (flags.find('g') != notFound) 77 77 flagsValue += 4; 78 if (flags.find('i') != UString::NotFound)78 if (flags.find('i') != notFound) 79 79 flagsValue += 2; 80 if (flags.find('m') != UString::NotFound)80 if (flags.find('m') != notFound) 81 81 flagsValue += 1; 82 82 return flagsValue; -
trunk/JavaScriptCore/runtime/StringPrototype.cpp
r65177 r65468 152 152 // ------------------------------ Functions -------------------------- 153 153 154 static NEVER_INLINE UString substituteBackreferencesSlow(const UString& replacement, const UString& source, const int* ovector, RegExp* reg, unsignedi)154 static NEVER_INLINE UString substituteBackreferencesSlow(const UString& replacement, const UString& source, const int* ovector, RegExp* reg, size_t i) 155 155 { 156 156 Vector<UChar> substitutedReplacement; … … 208 208 offset = i + 1; 209 209 substitutedReplacement.append(source.characters() + backrefStart, backrefLength); 210 } while ((i = replacement.find('$', i + 1)) != UString::NotFound);210 } while ((i = replacement.find('$', i + 1)) != notFound); 211 211 212 212 if (replacement.length() - offset) … … 219 219 static inline UString substituteBackreferences(const UString& replacement, const UString& source, const int* ovector, RegExp* reg) 220 220 { 221 unsignedi = replacement.find('$', 0);222 if (UNLIKELY(i != UString::NotFound))221 size_t i = replacement.find('$', 0); 222 if (UNLIKELY(i != notFound)) 223 223 return substituteBackreferencesSlow(replacement, source, ovector, reg, i); 224 224 return replacement; … … 430 430 431 431 const UString& source = sourceVal->value(exec); 432 unsignedmatchPos = source.find(patternString);433 434 if (matchPos == UString::NotFound)432 size_t matchPos = source.find(patternString); 433 434 if (matchPos == notFound) 435 435 return JSValue::encode(sourceVal); 436 436 … … 543 543 } 544 544 545 unsignedresult = s.find(u2, pos);546 if (result == UString::NotFound)545 size_t result = s.find(u2, pos); 546 if (result == notFound) 547 547 return JSValue::encode(jsNumber(exec, -1)); 548 548 return JSValue::encode(jsNumber(exec, result)); … … 572 572 #endif 573 573 574 unsigned result = s.rfind(u2, static_cast<unsigned>(dpos));575 if (result == UString::NotFound)574 size_t result = s.reverseFind(u2, static_cast<unsigned>(dpos)); 575 if (result == notFound) 576 576 return JSValue::encode(jsNumber(exec, -1)); 577 577 return JSValue::encode(jsNumber(exec, result)); … … 737 737 result->put(exec, i++, jsSingleCharacterSubstring(exec, s, p0++)); 738 738 } else { 739 unsigned pos; 740 741 while (i != limit && (pos = s.find(u2, p0)) != UString::NotFound) { 739 size_t pos; 740 while (i != limit && (pos = s.find(u2, p0)) != notFound) { 742 741 result->put(exec, i++, jsSubstring(exec, s, p0, pos - p0)); 743 742 p0 = pos + u2.length(); -
trunk/JavaScriptCore/runtime/UString.cpp
r65344 r65468 414 414 } 415 415 416 unsigned UString::find(const UString& f, unsigned pos) const417 {418 unsigned fsz = f.length();419 420 if (fsz == 1) {421 UChar ch = f[0];422 const UChar* end = characters() + length();423 for (const UChar* c = characters() + pos; c < end; c++) {424 if (*c == ch)425 return static_cast<unsigned>(c - characters());426 }427 return NotFound;428 }429 430 unsigned sz = length();431 if (sz < fsz)432 return NotFound;433 if (fsz == 0)434 return pos;435 const UChar* end = characters() + sz - fsz;436 unsigned fsizeminusone = (fsz - 1) * sizeof(UChar);437 const UChar* fdata = f.characters();438 unsigned short fchar = fdata[0];439 ++fdata;440 for (const UChar* c = characters() + pos; c <= end; c++) {441 if (c[0] == fchar && !memcmp(c + 1, fdata, fsizeminusone))442 return static_cast<unsigned>(c - characters());443 }444 445 return NotFound;446 }447 448 unsigned UString::find(UChar ch, unsigned pos) const449 {450 const UChar* end = characters() + length();451 for (const UChar* c = characters() + pos; c < end; c++) {452 if (*c == ch)453 return static_cast<unsigned>(c - characters());454 }455 456 return NotFound;457 }458 459 unsigned UString::rfind(const UString& f, unsigned pos) const460 {461 unsigned sz = length();462 unsigned fsz = f.length();463 if (sz < fsz)464 return NotFound;465 if (pos > sz - fsz)466 pos = sz - fsz;467 if (fsz == 0)468 return pos;469 unsigned fsizeminusone = (fsz - 1) * sizeof(UChar);470 const UChar* fdata = f.characters();471 for (const UChar* c = characters() + pos; c >= characters(); c--) {472 if (*c == *fdata && !memcmp(c + 1, fdata + 1, fsizeminusone))473 return static_cast<unsigned>(c - characters());474 }475 476 return NotFound;477 }478 479 unsigned UString::rfind(UChar ch, unsigned pos) const480 {481 if (isEmpty())482 return NotFound;483 if (pos + 1 >= length())484 pos = length() - 1;485 for (const UChar* c = characters() + pos; c >= characters(); c--) {486 if (*c == ch)487 return static_cast<unsigned>(c - characters());488 }489 490 return NotFound;491 }492 493 416 UString UString::substr(unsigned pos, unsigned len) const 494 417 { -
trunk/JavaScriptCore/runtime/UString.h
r65344 r65468 105 105 static UString number(double); 106 106 107 107 // Find a single character or string, also with match function & latin1 forms. 108 size_t find(UChar c, unsigned start = 0) const 109 { return m_impl ? m_impl->find(c, start) : notFound; } 110 size_t find(const UString& str, unsigned start = 0) const 111 { return m_impl ? m_impl->find(str.impl(), start) : notFound; } 112 size_t find(const char* str, unsigned start = 0) const 113 { return m_impl ? m_impl->find(str, start) : notFound; } 114 115 // Find the last instance of a single character or string. 116 size_t reverseFind(UChar c, unsigned start = UINT_MAX) const 117 { return m_impl ? m_impl->reverseFind(c, start) : notFound; } 118 size_t reverseFind(const UString& str, unsigned start = UINT_MAX) const 119 { return m_impl ? m_impl->reverseFind(str.impl(), start) : notFound; } 108 120 109 121 double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const; … … 115 127 uint32_t toStrictUInt32(bool* ok = 0) const; 116 128 117 static const unsigned NotFound = 0xFFFFFFFFu; 118 unsigned find(const UString& f, unsigned pos = 0) const; 119 unsigned find(UChar, unsigned pos = 0) const; 120 unsigned rfind(const UString& f, unsigned pos) const; 121 unsigned rfind(UChar, unsigned pos) const; 122 123 UString substr(unsigned pos = 0, unsigned len = 0xFFFFFFFF) const; 129 UString substr(unsigned pos = 0, unsigned len = UINT_MAX) const; 124 130 125 131 private:
Note:
See TracChangeset
for help on using the changeset viewer.