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

Unified Diff: third_party/WebKit/Source/platform/fonts/FontDataCache.h

Issue 2031363002: Use a FontPlatformData pointer for FontDataCache's key (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Crashes, lifecycle issues fixed Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/FontDataCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/FontDataCache.h
diff --git a/third_party/WebKit/Source/platform/fonts/FontDataCache.h b/third_party/WebKit/Source/platform/fonts/FontDataCache.h
index 3652e0350b1479675a59fdeb504e315eeb6a056f..f08d5cfd8c8acbb192840d9209980d615e74cea0 100644
--- a/third_party/WebKit/Source/platform/fonts/FontDataCache.h
+++ b/third_party/WebKit/Source/platform/fonts/FontDataCache.h
@@ -42,35 +42,29 @@ class SimpleFontData;
struct FontDataCacheKeyHash {
STATIC_ONLY(FontDataCacheKeyHash);
- static unsigned hash(const FontPlatformData& platformData)
+ static unsigned hash(const FontPlatformData* platformData)
{
- return platformData.hash();
+ return platformData->hash();
}
- static bool equal(const FontPlatformData& a, const FontPlatformData& b)
+ static bool equal(const FontPlatformData* a, const FontPlatformData* b)
{
- return a == b;
- }
+ const FontPlatformData* emptyValue = reinterpret_cast<FontPlatformData*>(-1);
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
+ if (a == emptyValue)
eae 2016/06/06 17:26:53 What's the difference between emptyValue (-1) and
+ return b == emptyValue;
+ if (b == emptyValue)
+ return a == emptyValue;
-struct FontDataCacheKeyTraits : WTF::GenericHashTraits<FontPlatformData> {
- STATIC_ONLY(FontDataCacheKeyTraits);
- static const bool emptyValueIsZero = true;
- static const FontPlatformData& emptyValue()
- {
- DEFINE_STATIC_LOCAL(FontPlatformData, key, (0.f, false, false));
- return key;
- }
- static void constructDeletedValue(FontPlatformData& slot, bool)
- {
- new (NotNull, &slot) FontPlatformData(WTF::HashTableDeletedValue);
- }
- static bool isDeletedValue(const FontPlatformData& value)
- {
- return value.isHashTableDeletedValue();
+ if (!a || !b)
+ return a == b;
+
+ CHECK(a && b);
+
+ return *a == *b;
}
+
+ static const bool safeToCompareToEmptyOrDeleted = true;
};
class FontDataCache {
@@ -94,7 +88,7 @@ public:
private:
bool purgeLeastRecentlyUsed(int count);
- typedef HashMap<FontPlatformData, std::pair<RefPtr<SimpleFontData>, unsigned>, FontDataCacheKeyHash, FontDataCacheKeyTraits> Cache;
+ typedef HashMap<const FontPlatformData*, std::pair<RefPtr<SimpleFontData>, unsigned>, FontDataCacheKeyHash> Cache;
Cache m_cache;
ListHashSet<RefPtr<SimpleFontData>> m_inactiveFontData;
};
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/FontDataCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698