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

Issue 160062: Hashing string16s. (Closed)

Created:
11 years, 5 months ago by jorlow
Modified:
9 years, 6 months ago
CC:
chromium-reviews_googlegroups.com, brettw
Visibility:
Public.

Description

I'm apparently the first one who's tried to do hash_map<string16, ...>. Unfortunately, hash_map<> does not know how to hash a string16 when string16 isn't a wstring. I looked in <tr1/functional> and saw that only std::string and std::wstring have hashing functions. This change adds a hashing function for string16's when they're not the same as a std::wstring. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=21494

Patch Set 1 #

Total comments: 10

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 6

Patch Set 4 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+28 lines, -0 lines) Patch
M base/hash_tables.h View 1 2 3 2 chunks +28 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
jorlow
Added the guard Darin suggested. Please take a look?
11 years, 5 months ago (2009-07-23 23:20:10 UTC) #1
Mark Mentovai
LG otherwise http://codereview.chromium.org/160062/diff/1/2 File base/hash_tables.h (right): http://codereview.chromium.org/160062/diff/1/2#newcode19 Line 19: #include "build/build_config.h" When this file is ...
11 years, 5 months ago (2009-07-23 23:27:40 UTC) #2
jorlow
New version uploaded. http://codereview.chromium.org/160062/diff/1/2 File base/hash_tables.h (right): http://codereview.chromium.org/160062/diff/1/2#newcode19 Line 19: #include "build/build_config.h" On 2009/07/23 23:27:40, ...
11 years, 5 months ago (2009-07-23 23:41:59 UTC) #3
Mark Mentovai
LGTM http://codereview.chromium.org/160062/diff/1006/1007 File base/hash_tables.h (right): http://codereview.chromium.org/160062/diff/1006/1007#newcode101 Line 101: return std::tr1::hash<long>()((long) i); You don't have to ...
11 years, 5 months ago (2009-07-24 00:01:33 UTC) #4
jorlow
11 years, 5 months ago (2009-07-24 00:12:29 UTC) #5
Submitting.

http://codereview.chromium.org/160062/diff/1006/1007
File base/hash_tables.h (right):

http://codereview.chromium.org/160062/diff/1006/1007#newcode101
Line 101: return std::tr1::hash<long>()((long) i);
On 2009/07/24 00:01:33, Mark Mentovai wrote:
> You don't have to fix this in this CL.  You can do a follow-up, or if you
don't
> want it (or don't want to do it now), at the very least, definitely file a
bug.

What's the correct fix though?  I'm 99% sure std::tr1::hash<long long> is
undefined which is why they did this.

To be honest, I'm not sure this is terribly insane.  I think most long longs are
that way only to handle corner cases and thus it's not insane to assume the
higher order bits don't matter.

Anyway, I guess we can follow up in http://crbug.com/17606

http://codereview.chromium.org/160062/diff/1006/1007#newcode110
Line 110: // make it compile.  The lib only defines the hash for string and
wstrings.
On 2009/07/24 00:01:33, Mark Mentovai wrote:
> "strings and wstrings" or (my preference) "string and wstring"

Done.

http://codereview.chromium.org/160062/diff/1006/1007#newcode122
Line 122: // make it compile.  The lib only defines the hash for string and
wstrings.
On 2009/07/24 00:01:33, Mark Mentovai wrote:
> Ditto.

Done.

Powered by Google App Engine
This is Rietveld 408576698