Bug 140848 - Provide implementation for WTF::DefaultHash<bool>
Summary: Provide implementation for WTF::DefaultHash<bool>
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
Depends on:
Blocks: 140577 140858
  Show dependency treegraph
Reported: 2015-01-23 16:37 PST by Chris Dumez
Modified: 2015-01-24 11:25 PST (History)
7 users (show)

See Also:

Patch (3.52 KB, patch)
2015-01-23 16:46 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2015-01-23 16:37:51 PST
Provide implementation for WTF::DefaultHash<bool> so that we can use HashMap<std::pair<XXX, bool>> in the code base. Right now, the code has to use an integer type instead of a bool in the HashMap / HashSet to work around the issue.
Comment 1 Chris Dumez 2015-01-23 16:46:11 PST
Created attachment 245259 [details]
Comment 2 WebKit Commit Bot 2015-01-23 16:48:42 PST
Attachment 245259 [details] did not pass style-queue:

ERROR: Source/WTF/wtf/HashFunctions.h:176:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 4 files

If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Darin Adler 2015-01-24 07:57:57 PST
Comment on attachment 245259 [details]

Do we really want to take a single bit and run the intHash(uint8_t) function on it? Any of these might be better, and would give the same result:

    inline unsigned intHash(bool key)
        return key ? 0x62BAF5A0 : 0x4636B9C9;

    inline unsigned intHash(bool key)
        return 0x4636B9C9 + key * 0x1C843BD7;

    inline unsigned intHash(bool key)
        return 0x4636B9C9 + (((key << 30) - key) & 0x1C843BD7);
Comment 4 WebKit Commit Bot 2015-01-24 08:28:18 PST
Comment on attachment 245259 [details]

Clearing flags on attachment: 245259

Committed r179061: <http://trac.webkit.org/changeset/179061>
Comment 5 WebKit Commit Bot 2015-01-24 08:28:23 PST
All reviewed patches have been landed.  Closing bug.