Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: third_party/WebKit/Source/platform/fonts/Character.cpp

Issue 1545073002: Make Character::isCJKIdeographOrSymbol() faster for common characters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor simplification Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/Character.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/Character.cpp b/third_party/WebKit/Source/platform/fonts/Character.cpp
index f795cd90f14a18203a591766ee12d1e25a8e6026..b0dc240d950286ad8b231606f65e639ec169f338 100644
--- a/third_party/WebKit/Source/platform/fonts/Character.cpp
+++ b/third_party/WebKit/Source/platform/fonts/Character.cpp
@@ -342,16 +342,6 @@ bool Character::isCJKIdeographOrSymbol(UChar32 c)
if (c < 0x2C7)
return false;
- // Hash lookup for isolated symbols (those not part of a contiguous range)
- static HashSet<UChar32>* cjkIsolatedSymbols = 0;
- if (!cjkIsolatedSymbols) {
- cjkIsolatedSymbols = new HashSet<UChar32>();
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(cjkIsolatedSymbolsArray); ++i)
- cjkIsolatedSymbols->add(cjkIsolatedSymbolsArray[i]);
- }
- if (cjkIsolatedSymbols->contains(c))
- return true;
-
if (isCJKIdeograph(c))
return true;
@@ -393,7 +383,23 @@ bool Character::isCJKIdeographOrSymbol(UChar32 c)
0x1F200, 0x1F6FF
};
- return valueInIntervalList(cjkSymbolRanges, c);
+ if (c >= cjkSymbolRanges[0]
+ && c <= cjkSymbolRanges[WTF_ARRAY_LENGTH(cjkSymbolRanges) - 1]
+ && valueInIntervalList(cjkSymbolRanges, c)) {
+ return true;
+ }
+
+ if (c < 0x2020 && c > 0x2D9)
+ return false;
+
+ // Hash lookup for isolated symbols (those not part of a contiguous range)
+ static HashSet<UChar32>* cjkIsolatedSymbols = 0;
+ if (!cjkIsolatedSymbols) {
+ cjkIsolatedSymbols = new HashSet<UChar32>();
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(cjkIsolatedSymbolsArray); ++i)
+ cjkIsolatedSymbols->add(cjkIsolatedSymbolsArray[i]);
+ }
+ return cjkIsolatedSymbols->contains(c);
}
unsigned Character::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion, const TextJustify textJustify)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698