RESOLVED DUPLICATE of bug 223858223880
Stop using a hash as key in the FontCascadeCache
https://bugs.webkit.org/show_bug.cgi?id=223880
Summary Stop using a hash as key in the FontCascadeCache
Chris Dumez
Reported 2021-03-29 09:59:15 PDT
Stop using a hash as key in the FontCascadeCache. Instead, use HashTraits and use FontCascadeCacheKey as key.
Attachments
Patch (5.96 KB, patch)
2021-03-29 10:00 PDT, Chris Dumez
no flags
Patch (6.91 KB, patch)
2021-03-29 12:01 PDT, Chris Dumez
no flags
Patch (6.91 KB, patch)
2021-03-29 12:49 PDT, Chris Dumez
no flags
Patch (6.18 KB, patch)
2021-03-29 14:25 PDT, Chris Dumez
no flags
Patch (5.99 KB, patch)
2021-03-29 15:23 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2021-03-29 10:00:42 PDT
Darin Adler
Comment 2 2021-03-29 10:04:01 PDT
Comment on attachment 424540 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424540&action=review > Source/WebCore/platform/graphics/FontCache.cpp:462 > + auto addResult = m_fontCascadeCache.add(key, nullptr); This is going to require a change to Chris Lord’s patch to make the font cache work from non-main threads. We’ll have to isolate the strings in the key after adding it. > Source/WebCore/platform/graphics/FontCache.cpp:584 > + // FIXME: Should hash the key and the family name characters rather than making a hash out of other hashes. Also should use Hasher instead of IntegerHasher. And, yes, I know that’s how we got into this mess in the first place.
Chris Dumez
Comment 3 2021-03-29 12:01:36 PDT
Chris Dumez
Comment 4 2021-03-29 12:49:38 PDT
Darin Adler
Comment 5 2021-03-29 13:43:11 PDT
Comment on attachment 424565 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424565&action=review > Source/WebCore/platform/graphics/FontCache.cpp:406 > +bool FontCascadeCacheKey::operator==(const FontCascadeCacheKey& other) const This does’t need to be a member function. Could just rename from keysMatch to operator== and leave it as a non-member function. > Source/WebCore/platform/graphics/FontCache.cpp:590 > + for (unsigned i = 0; i < key.families.size(); ++i) { > + auto& family = key.families[i]; How about a modern for loop? for (auto& family : key.families) {
Chris Dumez
Comment 6 2021-03-29 14:22:38 PDT
(In reply to Darin Adler from comment #5) > Comment on attachment 424565 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=424565&action=review > > > Source/WebCore/platform/graphics/FontCache.cpp:406 > > +bool FontCascadeCacheKey::operator==(const FontCascadeCacheKey& other) const > > This does’t need to be a member function. Could just rename from keysMatch > to operator== and leave it as a non-member function. > > > Source/WebCore/platform/graphics/FontCache.cpp:590 > > + for (unsigned i = 0; i < key.families.size(); ++i) { > > + auto& family = key.families[i]; > > How about a modern for loop? > > for (auto& family : key.families) { But having the index is convenient to look up the family in the "other" object.
Chris Dumez
Comment 7 2021-03-29 14:25:34 PDT
Darin Adler
Comment 8 2021-03-29 15:05:04 PDT
Comment on attachment 424565 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424565&action=review >>> Source/WebCore/platform/graphics/FontCache.cpp:406 >>> +bool FontCascadeCacheKey::operator==(const FontCascadeCacheKey& other) const >> >> This does’t need to be a member function. Could just rename from keysMatch to operator== and leave it as a non-member function. > > But having the index is convenient to look up the family in the "other" object. In the == function, but I was talking about the hash function.
Darin Adler
Comment 9 2021-03-29 15:06:48 PDT
Comment on attachment 424579 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424579&action=review > Source/WebCore/platform/graphics/FontCache.cpp:590 > + for (unsigned i = 0; i < key.families.size(); ++i) { > + auto& family = key.families[i]; Unlike the == function, this can use the modern for loop. > Source/WebCore/platform/graphics/FontCache.h:199 > +namespace WTF { We don’t need to put this in the WTF namespace. It doesn’t have to the the default hash for FontCascadeCacheKey. It can just be the hash we pass to the HashMap template. > Source/WebCore/platform/graphics/FontCache.h:219 > +typedef HashMap<FontCascadeCacheKey, std::unique_ptr<FontCascadeCacheEntry>> FontCascadeCache; How about using instead of typedef since we have to touch this line?
Chris Dumez
Comment 10 2021-03-29 15:23:59 PDT
Chris Dumez
Comment 11 2021-03-29 15:28:21 PDT
*** This bug has been marked as a duplicate of bug 223858 ***
Note You need to log in before you can comment on or make changes to this bug.