Changeset 102059 in webkit
- Timestamp:
- Dec 5, 2011, 3:56:49 PM (15 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/wtf/text/WTFString.h (modified) (3 diffs)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/KURL.cpp (modified) (1 diff)
-
WebCore/platform/cf/BinaryPropertyList.cpp (modified) (1 diff)
-
WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r102057 r102059 1 2011-12-05 Benjamin Poulain <benjamin@webkit.org> 2 3 Update String::containsOnlyASCII() to handle 8 bits strings 4 https://bugs.webkit.org/show_bug.cgi?id=73799 5 6 Reviewed by Darin Adler. 7 8 Implement String::containsOnlyASCII() so that it does not 9 call String::characters(). 10 11 * wtf/text/WTFString.h: 12 (WTF::String::containsOnlyASCII): 13 1 14 2011-12-05 Filip Pizlo <fpizlo@apple.com> 2 15 -
trunk/Source/JavaScriptCore/wtf/text/WTFString.h
r102028 r102059 62 62 // Declarations of string operations 63 63 64 bool charactersAreAllASCII(const UChar*, size_t);64 template<typename CharType> inline bool charactersAreAllASCII(const CharType* characters, size_t length); 65 65 WTF_EXPORT_PRIVATE int charactersToIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10); 66 66 WTF_EXPORT_PRIVATE int charactersToIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10); … … 374 374 } 375 375 376 bool containsOnlyASCII() const { return charactersAreAllASCII(characters(), length()); }376 bool containsOnlyASCII() const; 377 377 bool containsOnlyLatin1() const; 378 378 bool containsOnlyWhitespace() const { return !m_impl || m_impl->containsOnlyWhitespace(); } … … 483 483 #endif 484 484 485 inline bool charactersAreAllASCII(const UChar* characters, size_t length) 486 { 487 UChar ored = 0; 485 template<typename CharType> 486 inline bool charactersAreAllASCII(const CharType* characters, size_t length) 487 { 488 CharType ored = 0; 488 489 for (size_t i = 0; i < length; ++i) 489 490 ored |= characters[i]; 490 return !(ored & 0xFF80); 491 492 CharType lowBits = 0x7F; 493 return !(ored & ~lowBits); 494 } 495 496 inline bool String::containsOnlyASCII() const 497 { 498 if (isEmpty()) 499 return true; 500 501 if (is8Bit()) 502 return charactersAreAllASCII(characters8(), m_impl->length()); 503 504 return charactersAreAllASCII(characters16(), m_impl->length()); 491 505 } 492 506 -
trunk/Source/WebCore/ChangeLog
r102055 r102059 1 2011-12-05 Benjamin Poulain <benjamin@webkit.org> 2 3 Update String::containsOnlyASCII() to handle 8 bits strings 4 https://bugs.webkit.org/show_bug.cgi?id=73799 5 6 Reviewed by Darin Adler. 7 8 When possible, change the call sites from charactersAreAllASCII() 9 to the optimized version String::containsOnlyASCII(). 10 11 * platform/KURL.cpp: 12 (WebCore::KURL::init): 13 * platform/cf/BinaryPropertyList.cpp: 14 (WebCore::BinaryPropertyListPlan::writeStringObject): 15 * platform/graphics/chromium/FontCacheChromiumWin.cpp: 16 (WebCore::FontCodepage::if): 17 1 18 2011-12-01 Vangelis Kokkevis <vangelis@chromium.org> 2 19 -
trunk/Source/WebCore/platform/KURL.cpp
r101713 r102059 377 377 rel = substituteBackslashes(rel); 378 378 379 bool allASCII = charactersAreAllASCII(rel.characters(), rel.length());379 bool allASCII = rel.containsOnlyASCII(); 380 380 CharBuffer strBuffer; 381 381 char* str; -
trunk/Source/WebCore/platform/cf/BinaryPropertyList.cpp
r81548 r102059 286 286 void BinaryPropertyListPlan::writeStringObject(const String& string) 287 287 { 288 const UChar* characters = string.characters();289 288 unsigned length = string.length(); 290 289 m_byteCount += markerPlusLengthByteCount(length) + length; 291 if (! charactersAreAllASCII(characters, length))290 if (!string.containsOnlyASCII()) 292 291 m_byteCount += length; 293 292 } -
trunk/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp
r95901 r102059 50 50 namespace WebCore 51 51 { 52 53 // FIXME: consider adding to WebKit String class54 static bool charactersAreAllASCII(const String& s)55 {56 return WTF::charactersAreAllASCII(s.characters(), s.length());57 }58 52 59 53 // When asked for a CJK font with a native name under a non-CJK locale or … … 217 211 // For non-ASCII names, we don't want to invoke an expensive 218 212 // and unnecessary |lower|. 219 if ( charactersAreAllASCII(name)) {213 if (name.containsOnlyASCII()) { 220 214 isAscii = true; 221 215 n = name.lower();
Note:
See TracChangeset
for help on using the changeset viewer.