Changeset 60332 in webkit
- Timestamp:
- May 27, 2010 4:43:54 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r60328 r60332 1 2010-05-27 Luiz Agostini <luiz.agostini@openbossa.org> 2 3 Reviewed by Darin Adler. 4 5 UTF-16 code points compare() for String objects 6 https://bugs.webkit.org/show_bug.cgi?id=39701 7 8 Moving compare() implementation from UString to StringImpl for it to be shared 9 with String. Adding overloaded free functions codePointCompare() in StringImpl 10 and WTFString. Renaming function compare in UString to codePointCompare to be 11 consistent. 12 13 * runtime/JSArray.cpp: 14 (JSC::compareByStringPairForQSort): 15 * runtime/UString.cpp: 16 * runtime/UString.h: 17 (JSC::codePointCompare): 18 * wtf/text/StringImpl.cpp: 19 (WebCore::codePointCompare): 20 * wtf/text/StringImpl.h: 21 * wtf/text/WTFString.cpp: 22 (WebCore::codePointCompare): 23 * wtf/text/WTFString.h: 24 1 25 2010-05-26 Darin Adler <darin@apple.com> 2 26 -
trunk/JavaScriptCore/runtime/JSArray.cpp
r55262 r60332 650 650 const ValueStringPair* va = static_cast<const ValueStringPair*>(a); 651 651 const ValueStringPair* vb = static_cast<const ValueStringPair*>(b); 652 return co mpare(va->second, vb->second);652 return codePointCompare(va->second, vb->second); 653 653 } 654 654 -
trunk/JavaScriptCore/runtime/UString.cpp
r60328 r60332 581 581 } 582 582 583 int compare(const UString& s1, const UString& s2)584 {585 const unsigned l1 = s1.size();586 const unsigned l2 = s2.size();587 const unsigned lmin = l1 < l2 ? l1 : l2;588 const UChar* c1 = s1.data();589 const UChar* c2 = s2.data();590 unsigned l = 0;591 while (l < lmin && *c1 == *c2) {592 c1++;593 c2++;594 l++;595 }596 597 if (l < lmin)598 return (c1[0] > c2[0]) ? 1 : -1;599 600 if (l1 == l2)601 return 0;602 603 return (l1 > l2) ? 1 : -1;604 }605 606 583 CString UString::UTF8String(bool strict) const 607 584 { -
trunk/JavaScriptCore/runtime/UString.h
r59337 r60332 203 203 } 204 204 205 int compare(const UString&, const UString&); 205 inline int codePointCompare(const UString& s1, const UString& s2) 206 { 207 return codePointCompare(s1.rep(), s2.rep()); 208 } 206 209 207 210 // Rule from ECMA 15.2 about what an array index is. -
trunk/JavaScriptCore/wtf/text/StringImpl.cpp
r59969 r60332 477 477 } 478 478 479 int codePointCompare(const StringImpl* s1, const StringImpl* s2) 480 { 481 const unsigned l1 = s1 ? s1->length() : 0; 482 const unsigned l2 = s2 ? s2->length() : 0; 483 const unsigned lmin = l1 < l2 ? l1 : l2; 484 const UChar* c1 = s1 ? s1->characters() : 0; 485 const UChar* c2 = s2 ? s2->characters() : 0; 486 unsigned pos = 0; 487 while (pos < lmin && *c1 == *c2) { 488 c1++; 489 c2++; 490 pos++; 491 } 492 493 if (pos < lmin) 494 return (c1[0] > c2[0]) ? 1 : -1; 495 496 if (l1 == l2) 497 return 0; 498 499 return (l1 > l2) ? 1 : -1; 500 } 501 479 502 int StringImpl::find(const char* chs, int index, bool caseSensitive) 480 503 { -
trunk/JavaScriptCore/wtf/text/StringImpl.h
r59358 r60332 353 353 bool equalIgnoringNullity(StringImpl*, StringImpl*); 354 354 355 int codePointCompare(const StringImpl*, const StringImpl*); 356 355 357 static inline bool isSpaceOrNewline(UChar c) 356 358 { -
trunk/JavaScriptCore/wtf/text/WTFString.cpp
r59196 r60332 127 127 } 128 128 129 int codePointCompare(const String& a, const String& b) 130 { 131 return codePointCompare(a.impl(), b.impl()); 132 } 133 129 134 void String::insert(const String& str, unsigned pos) 130 135 { -
trunk/JavaScriptCore/wtf/text/WTFString.h
r59202 r60332 352 352 } 353 353 354 int codePointCompare(const String&, const String&); 355 354 356 inline int find(const UChar* characters, size_t length, UChar character, int startPosition) 355 357 {
Note: See TracChangeset
for help on using the changeset viewer.