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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeCache.h

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs Created 3 years, 10 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) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2015 Google Inc. All rights reserved. 3 * Copyright (C) 2015 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 ShapeCacheEntry* addSlowCase(const TextRun& run, ShapeCacheEntry entry) { 183 ShapeCacheEntry* addSlowCase(const TextRun& run, ShapeCacheEntry entry) {
184 unsigned length = run.length(); 184 unsigned length = run.length();
185 bool isNewEntry; 185 bool isNewEntry;
186 ShapeCacheEntry* value; 186 ShapeCacheEntry* value;
187 if (length == 1) { 187 if (length == 1) {
188 uint32_t key = run[0]; 188 uint32_t key = run[0];
189 // All current codepointsin UTF-32 are bewteen 0x0 and 0x10FFFF, 189 // All current codepointsin UTF-32 are bewteen 0x0 and 0x10FFFF,
190 // as such use bit 32 to indicate direction. 190 // as such use bit 32 to indicate direction.
191 if (run.direction() == TextDirection::kRtl) 191 if (run.direction() == TextDirection::kRtl)
192 key |= (1u << 31); 192 key |= (1u << 31);
193 SingleCharMap::AddResult addResult = m_singleCharMap.add(key, entry); 193 SingleCharMap::AddResult addResult = m_singleCharMap.insert(key, entry);
194 isNewEntry = addResult.isNewEntry; 194 isNewEntry = addResult.isNewEntry;
195 value = &addResult.storedValue->value; 195 value = &addResult.storedValue->value;
196 } else { 196 } else {
197 SmallStringKey smallStringKey; 197 SmallStringKey smallStringKey;
198 if (run.is8Bit()) 198 if (run.is8Bit())
199 smallStringKey = 199 smallStringKey =
200 SmallStringKey(run.characters8(), length, run.direction()); 200 SmallStringKey(run.characters8(), length, run.direction());
201 else 201 else
202 smallStringKey = 202 smallStringKey =
203 SmallStringKey(run.characters16(), length, run.direction()); 203 SmallStringKey(run.characters16(), length, run.direction());
204 204
205 SmallStringMap::AddResult addResult = 205 SmallStringMap::AddResult addResult =
206 m_shortStringMap.add(smallStringKey, entry); 206 m_shortStringMap.insert(smallStringKey, entry);
207 isNewEntry = addResult.isNewEntry; 207 isNewEntry = addResult.isNewEntry;
208 value = &addResult.storedValue->value; 208 value = &addResult.storedValue->value;
209 } 209 }
210 210
211 if (!isNewEntry) 211 if (!isNewEntry)
212 return value; 212 return value;
213 213
214 if (size() < s_maxSize) 214 if (size() < s_maxSize)
215 return value; 215 return value;
216 216
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 inline bool operator==(const ShapeCache::SmallStringKey& a, 250 inline bool operator==(const ShapeCache::SmallStringKey& a,
251 const ShapeCache::SmallStringKey& b) { 251 const ShapeCache::SmallStringKey& b) {
252 if (a.length() != b.length() || a.direction() != b.direction()) 252 if (a.length() != b.length() || a.direction() != b.direction())
253 return false; 253 return false;
254 return WTF::equal(a.characters(), b.characters(), a.length()); 254 return WTF::equal(a.characters(), b.characters(), a.length());
255 } 255 }
256 256
257 } // namespace blink 257 } // namespace blink
258 258
259 #endif // ShapeCache_h 259 #endif // ShapeCache_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698