WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
147866
Implement IntegerHasher
https://bugs.webkit.org/show_bug.cgi?id=147866
Summary
Implement IntegerHasher
Myles C. Maxfield
Reported
2015-08-10 21:23:25 PDT
[font-features] Addressing post-commit review of
r188088
Attachments
Patch
(1.86 KB, patch)
2015-08-10 21:26 PDT
,
Myles C. Maxfield
darin
: review+
Details
Formatted Diff
Diff
Patch
(39.79 KB, patch)
2015-08-17 15:55 PDT
,
Myles C. Maxfield
andersca
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Myles C. Maxfield
Comment 1
2015-08-10 21:26:19 PDT
Created
attachment 258698
[details]
Patch
Darin Adler
Comment 2
2015-08-10 22:49:54 PDT
Comment on
attachment 258698
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=258698&action=review
Side questions: 1: Why isn’t m_tag in FontFeature marked const? 2: Generally speaking, FontFeature seems to be a custom-written pair; is there a way to use more of std::pair in its implementation? 3: Why so many includes in this header? I don’t think we need to include anything other than Vector.h and AtomicString.h.
> Source/WebCore/platform/graphics/FontFeatureSettings.cpp:79 > + static_assert(sizeof(unsigned) == sizeof(UChar) * 2, "Must be able to use StringHasher::addCharacters()"); > + for (size_t i = 0; i < size(); ++i) { > + unsigned featureHash = at(i).hash(); > + UChar lower = featureHash; > + UChar upper = featureHash >> (sizeof(UChar) * 8); > + hasher.addCharacters(upper, lower); > + }
I’d write this: for (auto& feature : m_list) { unsigned hash = feature.hash(); hasher.addCharactersAssumingAligned(hash, hash >> 16); } I don’t think we should try to be abstract about how many bits there are in a UChar. And there's no reason to compile in the code to handle unaligned hashing. If you want to make it even cleaner, we could write something called IntegerHasher, like this: class IntegerHasher { public: void add(unsigned integer) { m_underlyingHasher.addCharactersAssumingAligned(integer, integer >> 16); } unsigned hash() const { return m_underlyingHasher.hash(); } private: StringHasher m_underlyingHasher; } Then: for (auto& feature : m_list) hasher.add(feature.hash()); Finally, I’m not really sure it’s good to be hashing hashes so excessively. Maybe use the hashes of the tag strings, but for the rest it seems excessive to hash just so we can hash again. Maybe like this: for (auto& feature : m_list) { hasher.add(feature.tag().hash()); hasher.add(feature.value()); }
Myles C. Maxfield
Comment 3
2015-08-17 15:55:21 PDT
Created
attachment 259196
[details]
Patch
Anders Carlsson
Comment 4
2015-08-17 15:57:26 PDT
Comment on
attachment 259196
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=259196&action=review
> Source/WTF/wtf/Hasher.h:295 > +
No need for a newline here.
Myles C. Maxfield
Comment 5
2015-08-17 16:59:13 PDT
Committed
r188557
: <
http://trac.webkit.org/changeset/188557
>
Frédéric Wang (:fredw)
Comment 6
2018-11-06 03:43:02 PST
Comment on
attachment 259196
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=259196&action=review
> Source/WebCore/platform/graphics/FontFeatureSettings.cpp:67 > + IntegerHasher hasher;
This bug is very old but probably we needed to include <wtf/Hasher.h> in order to use IntegerHash here. I just landed a commit adding this header.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug