Bug 140848

Summary: Provide implementation for WTF::DefaultHash<bool>
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web Template FrameworkAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, benjamin, cmarcelo, commit-queue, koivisto, mmaxfield, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 140577, 140858    
Attachments:
Description Flags
Patch none

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]
Patch
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]
Patch

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]
Patch

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.