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

Side by Side Diff: src/base/functional.h

Issue 632713002: Don't use identity as hash function for integers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/base/functional.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_BASE_FUNCTIONAL_H_ 5 #ifndef V8_BASE_FUNCTIONAL_H_
6 #define V8_BASE_FUNCTIONAL_H_ 6 #define V8_BASE_FUNCTIONAL_H_
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <functional> 9 #include <functional>
10 #include <utility> 10 #include <utility>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 inline size_t hash_combine(T const& v, Ts const&... vs) { 69 inline size_t hash_combine(T const& v, Ts const&... vs) {
70 return hash_combine(hash<T>()(v), hash_combine(vs...)); 70 return hash_combine(hash<T>()(v), hash_combine(vs...));
71 } 71 }
72 72
73 73
74 #define V8_BASE_HASH_VALUE_TRIVIAL(type) \ 74 #define V8_BASE_HASH_VALUE_TRIVIAL(type) \
75 inline size_t hash_value(type v) { return static_cast<size_t>(v); } 75 inline size_t hash_value(type v) { return static_cast<size_t>(v); }
76 V8_BASE_HASH_VALUE_TRIVIAL(bool) 76 V8_BASE_HASH_VALUE_TRIVIAL(bool)
77 V8_BASE_HASH_VALUE_TRIVIAL(unsigned char) 77 V8_BASE_HASH_VALUE_TRIVIAL(unsigned char)
78 V8_BASE_HASH_VALUE_TRIVIAL(unsigned short) // NOLINT(runtime/int) 78 V8_BASE_HASH_VALUE_TRIVIAL(unsigned short) // NOLINT(runtime/int)
79 V8_BASE_HASH_VALUE_TRIVIAL(unsigned int)
80 #undef V8_BASE_HASH_VALUE_TRIVIAL 79 #undef V8_BASE_HASH_VALUE_TRIVIAL
81 80
82 size_t hash_value(unsigned long v); // NOLINT(runtime/int) 81 size_t hash_value(unsigned int);
83 size_t hash_value(unsigned long long v); // NOLINT(runtime/int) 82 size_t hash_value(unsigned long); // NOLINT(runtime/int)
83 size_t hash_value(unsigned long long); // NOLINT(runtime/int)
84 84
85 #define V8_BASE_HASH_VALUE_SIGNED(type) \ 85 #define V8_BASE_HASH_VALUE_SIGNED(type) \
86 inline size_t hash_value(signed type v) { \ 86 inline size_t hash_value(signed type v) { \
87 return hash_value(bit_cast<unsigned type>(v)); \ 87 return hash_value(bit_cast<unsigned type>(v)); \
88 } 88 }
89 V8_BASE_HASH_VALUE_SIGNED(char) 89 V8_BASE_HASH_VALUE_SIGNED(char)
90 V8_BASE_HASH_VALUE_SIGNED(short) // NOLINT(runtime/int) 90 V8_BASE_HASH_VALUE_SIGNED(short) // NOLINT(runtime/int)
91 V8_BASE_HASH_VALUE_SIGNED(int) // NOLINT(runtime/int) 91 V8_BASE_HASH_VALUE_SIGNED(int) // NOLINT(runtime/int)
92 V8_BASE_HASH_VALUE_SIGNED(long) // NOLINT(runtime/int) 92 V8_BASE_HASH_VALUE_SIGNED(long) // NOLINT(runtime/int)
93 V8_BASE_HASH_VALUE_SIGNED(long long) // NOLINT(runtime/int) 93 V8_BASE_HASH_VALUE_SIGNED(long long) // NOLINT(runtime/int)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 : public std::unary_function<std::pair<T1, T2>, size_t> { 145 : public std::unary_function<std::pair<T1, T2>, size_t> {
146 size_t operator()(std::pair<T1, T2> const& v) const { 146 size_t operator()(std::pair<T1, T2> const& v) const {
147 return ::v8::base::hash_value(v); 147 return ::v8::base::hash_value(v);
148 } 148 }
149 }; 149 };
150 150
151 } // namespace base 151 } // namespace base
152 } // namespace v8 152 } // namespace v8
153 153
154 #endif // V8_BASE_FUNCTIONAL_H_ 154 #endif // V8_BASE_FUNCTIONAL_H_
OLDNEW
« no previous file with comments | « no previous file | src/base/functional.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698