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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontTest.cpp

Issue 1541393003: Improve performance of Character::isCJKIdeographOrSymbol by using trie tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup, remove isCJKIdeograph, remove perf test code Created 4 years, 11 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 static UChar c4[] = { 0x36F, 0x330 }; 158 static UChar c4[] = { 0x36F, 0x330 };
159 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c4, 2)); 159 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c4, 2));
160 // Surrogate-Complex is Complex 160 // Surrogate-Complex is Complex
161 static UChar c5[] = { 0xD83C, 0xDDE5, 0x330 }; 161 static UChar c5[] = { 0xD83C, 0xDDE5, 0x330 };
162 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c5, 3)); 162 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c5, 3));
163 // Complex-Surrogate is Complex 163 // Complex-Surrogate is Complex
164 static UChar c6[] = { 0x330, 0xD83C, 0xDDE5 }; 164 static UChar c6[] = { 0x330, 0xD83C, 0xDDE5 };
165 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c6, 3)); 165 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c6, 3));
166 } 166 }
167 167
168 static void TestSpecificUChar32RangeIdeograph(UChar32 rangeStart, UChar32 rangeE nd) 168 static void TestSpecificUChar32RangeIdeograph(UChar32 rangeStart, UChar32 rangeE nd, bool before = true)
169 { 169 {
170 EXPECT_FALSE(Character::isCJKIdeograph(rangeStart - 1)); 170 if (before)
171 EXPECT_TRUE(Character::isCJKIdeograph(rangeStart)); 171 EXPECT_FALSE(Character::isCJKIdeographOrSymbol(rangeStart - 1));
172 EXPECT_TRUE(Character::isCJKIdeograph((UChar32)((uint64_t)rangeStart + (uint 64_t)rangeEnd) / 2)); 172 EXPECT_TRUE(Character::isCJKIdeographOrSymbol(rangeStart));
173 EXPECT_TRUE(Character::isCJKIdeograph(rangeEnd)); 173 EXPECT_TRUE(Character::isCJKIdeographOrSymbol((UChar32)((uint64_t)rangeStart + (uint64_t)rangeEnd) / 2));
174 EXPECT_FALSE(Character::isCJKIdeograph(rangeEnd + 1)); 174 EXPECT_TRUE(Character::isCJKIdeographOrSymbol(rangeEnd));
175 EXPECT_FALSE(Character::isCJKIdeographOrSymbol(rangeEnd + 1));
175 } 176 }
176 177
177 TEST(FontTest, TestIsCJKIdeograph) 178 TEST(FontTest, TestIsCJKIdeograph)
178 { 179 {
179 // The basic CJK Unified Ideographs block. 180 // The basic CJK Unified Ideographs block.
180 TestSpecificUChar32RangeIdeograph(0x4E00, 0x9FFF); 181 TestSpecificUChar32RangeIdeograph(0x4E00, 0x9FFF);
181 // CJK Unified Ideographs Extension A. 182 // CJK Unified Ideographs Extension A.
182 TestSpecificUChar32RangeIdeograph(0x3400, 0x4DBF); 183 TestSpecificUChar32RangeIdeograph(0x3400, 0x4DBF, false);
183 // CJK Unified Ideographs Extension A and Kangxi Radicals. 184 // CJK Unified Ideographs Extension A and Kangxi Radicals.
184 TestSpecificUChar32RangeIdeograph(0x2E80, 0x2FDF); 185 TestSpecificUChar32RangeIdeograph(0x2E80, 0x2FDF);
185 // CJK Strokes. 186 // CJK Strokes.
186 TestSpecificUChar32RangeIdeograph(0x31C0, 0x31EF); 187 TestSpecificUChar32RangeIdeograph(0x31C0, 0x31EF, false);
187 // CJK Compatibility Ideographs. 188 // CJK Compatibility Ideographs.
188 TestSpecificUChar32RangeIdeograph(0xF900, 0xFAFF); 189 TestSpecificUChar32RangeIdeograph(0xF900, 0xFAFF);
189 // CJK Unified Ideographs Extension B. 190 // CJK Unified Ideographs Extension B.
190 TestSpecificUChar32RangeIdeograph(0x20000, 0x2A6DF); 191 TestSpecificUChar32RangeIdeograph(0x20000, 0x2A6DF);
191 // CJK Unified Ideographs Extension C. 192 // CJK Unified Ideographs Extension C.
192 // CJK Unified Ideographs Extension D. 193 // CJK Unified Ideographs Extension D.
193 TestSpecificUChar32RangeIdeograph(0x2A700, 0x2B81F); 194 TestSpecificUChar32RangeIdeograph(0x2A700, 0x2B81F);
194 // CJK Compatibility Ideographs Supplement. 195 // CJK Compatibility Ideographs Supplement.
195 TestSpecificUChar32RangeIdeograph(0x2F800, 0x2FA1F); 196 TestSpecificUChar32RangeIdeograph(0x2F800, 0x2FA1F);
196 } 197 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 344
344 TestSpecificUChar32RangeIdeographSymbol(0x1F110, 0x1F129); 345 TestSpecificUChar32RangeIdeographSymbol(0x1F110, 0x1F129);
345 TestSpecificUChar32RangeIdeographSymbol(0x1F130, 0x1F149); 346 TestSpecificUChar32RangeIdeographSymbol(0x1F130, 0x1F149);
346 TestSpecificUChar32RangeIdeographSymbol(0x1F150, 0x1F169); 347 TestSpecificUChar32RangeIdeographSymbol(0x1F150, 0x1F169);
347 TestSpecificUChar32RangeIdeographSymbol(0x1F170, 0x1F189); 348 TestSpecificUChar32RangeIdeographSymbol(0x1F170, 0x1F189);
348 TestSpecificUChar32RangeIdeographSymbol(0x1F200, 0x1F6FF); 349 TestSpecificUChar32RangeIdeographSymbol(0x1F200, 0x1F6FF);
349 } 350 }
350 351
351 } // namespace blink 352 } // namespace blink
352 353
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698