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

Issue 10911330: Add methods for hashing pairs of integer values. (Closed)

Created:
8 years, 3 months ago by danakj
Modified:
8 years, 3 months ago
Reviewers:
enne (OOO)
CC:
chromium-reviews, erikwright+watch_chromium.org, cc-bugs_chromium.org, piman, jamesr, wjmaclean
Visibility:
Public.

Description

Add methods for hashing pairs of integer values. This will allow us to create hash_maps that are keyed off of std::pair objects holding two integer values. When both integers are at most 32-bits we can use 64-bit multiplication to efficiently find the hash code. When one of the integers is 64-bit, then we split the two values in the pair into 4 32-bit integers. References to the algorithms used are contained in comments within the code. These algorithms are similar to the hash function recently added to WebKit in https://bugs.webkit.org/show_bug.cgi?id=96022, however since our hash codes are of type size_t (theirs are unsigned) which is 64 bits large on some platforms, we can be more efficient and not have to reduce the hash code to 32 bits on some platforms. Tested by cc_unittests: HashPairTest.IntegerPairs. BUG=149870 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=158479

Patch Set 1 #

Patch Set 2 : odd where needed #

Patch Set 3 : fix build on some platforms #

Patch Set 4 : fix windows compile #

Total comments: 2

Patch Set 5 : Proper implementation of multiply-add hashing #

Patch Set 6 : current-windows-attempt #

Patch Set 7 : compiles at last #

Total comments: 3

Patch Set 8 : #

Patch Set 9 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+212 lines, -0 lines) Patch
M cc/cc.gyp View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download
M cc/cc_tests.gyp View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
A cc/hash_pair.h View 1 2 3 4 5 6 7 1 chunk +150 lines, -0 lines 0 comments Download
A cc/hash_pair_unittest.cc View 1 2 3 4 5 6 7 1 chunk +60 lines, -0 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
danakj
8 years, 3 months ago (2012-09-16 23:25:12 UTC) #1
jar (doing other things)
We don't generally add stuff to base until we see multiple uses of it, or ...
8 years, 3 months ago (2012-09-17 22:01:12 UTC) #2
danakj
On Mon, Sep 17, 2012 at 6:01 PM, <jar@chromium.org> wrote: > We don't generally add ...
8 years, 3 months ago (2012-09-18 23:09:24 UTC) #3
danakj
I still need to make windows compile with its confusing hash_map implementation, but PTAL at ...
8 years, 3 months ago (2012-09-19 00:04:14 UTC) #4
danakj
On 2012/09/19 00:04:14, danakj wrote: > I still need to make windows compile with its ...
8 years, 3 months ago (2012-09-21 02:14:04 UTC) #5
jar (doing other things)
Although it is plausible that we should add such a hash, I don't think it ...
8 years, 3 months ago (2012-09-24 20:52:21 UTC) #6
danakj
https://codereview.chromium.org/10911330/diff/27004/base/hash_tables.h File base/hash_tables.h (right): https://codereview.chromium.org/10911330/diff/27004/base/hash_tables.h#newcode195 base/hash_tables.h:195: uint32 shortRandom3 = 29379286U; \ All the random numbers ...
8 years, 3 months ago (2012-09-24 21:09:03 UTC) #7
danakj
I've moved the hash pair code into cc/ to unblock GTFO, and marked enne as ...
8 years, 3 months ago (2012-09-24 22:10:09 UTC) #8
enne (OOO)
Do you need to add hash_pair.h to some gyp file too?
8 years, 3 months ago (2012-09-24 22:12:02 UTC) #9
danakj
On 2012/09/24 22:12:02, enne wrote: > Do you need to add hash_pair.h to some gyp ...
8 years, 3 months ago (2012-09-24 22:14:26 UTC) #10
enne (OOO)
lgtm
8 years, 3 months ago (2012-09-24 22:17:20 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/danakj@chromium.org/10911330/40002
8 years, 3 months ago (2012-09-24 22:28:03 UTC) #12
commit-bot: I haz the power
8 years, 3 months ago (2012-09-25 01:05:02 UTC) #13
Change committed as 158479

Powered by Google App Engine
This is Rietveld 408576698