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

Side by Side Diff: tools/gn/label.h

Issue 623383002: Align base::hash_map with C++11, part 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hash-1
Patch Set: clean up stale includes Created 6 years, 1 month 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
« no previous file with comments | « net/dns/dns_hosts.h ('k') | tools/gn/label_ptr.h » ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium 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 TOOLS_GN_LABEL_H_ 5 #ifndef TOOLS_GN_LABEL_H_
6 #define TOOLS_GN_LABEL_H_ 6 #define TOOLS_GN_LABEL_H_
7 7
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "build/build_config.h"
10 #include "tools/gn/source_dir.h" 9 #include "tools/gn/source_dir.h"
11 10
12 class Err; 11 class Err;
13 class Value; 12 class Value;
14 13
15 // A label represents the name of a target or some other named thing in 14 // A label represents the name of a target or some other named thing in
16 // the source path. The label is always absolute and always includes a name 15 // the source path. The label is always absolute and always includes a name
17 // part, so it starts with a slash, and has one colon. 16 // part, so it starts with a slash, and has one colon.
18 class Label { 17 class Label {
19 public: 18 public:
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 private: 99 private:
101 SourceDir dir_; 100 SourceDir dir_;
102 std::string name_; 101 std::string name_;
103 102
104 SourceDir toolchain_dir_; 103 SourceDir toolchain_dir_;
105 std::string toolchain_name_; 104 std::string toolchain_name_;
106 }; 105 };
107 106
108 namespace BASE_HASH_NAMESPACE { 107 namespace BASE_HASH_NAMESPACE {
109 108
110 #if defined(COMPILER_GCC)
111 template<> struct hash<Label> { 109 template<> struct hash<Label> {
112 std::size_t operator()(const Label& v) const { 110 std::size_t operator()(const Label& v) const {
113 hash<std::string> stringhash; 111 hash<std::string> stringhash;
114 return ((stringhash(v.dir().value()) * 131 + 112 return ((stringhash(v.dir().value()) * 131 +
115 stringhash(v.name())) * 131 + 113 stringhash(v.name())) * 131 +
116 stringhash(v.toolchain_dir().value())) * 131 + 114 stringhash(v.toolchain_dir().value())) * 131 +
117 stringhash(v.toolchain_name()); 115 stringhash(v.toolchain_name());
118 } 116 }
119 }; 117 };
120 #elif defined(COMPILER_MSVC)
121 inline size_t hash_value(const Label& v) {
122 return ((hash_value(v.dir().value()) * 131 +
123 hash_value(v.name())) * 131 +
124 hash_value(v.toolchain_dir().value())) * 131 +
125 hash_value(v.toolchain_name());
126 }
127 #endif // COMPILER...
128 118
129 } // namespace BASE_HASH_NAMESPACE 119 } // namespace BASE_HASH_NAMESPACE
130 120
131 inline void swap(Label& lhs, Label& rhs) { 121 inline void swap(Label& lhs, Label& rhs) {
132 lhs.swap(rhs); 122 lhs.swap(rhs);
133 } 123 }
134 124
135 #endif // TOOLS_GN_LABEL_H_ 125 #endif // TOOLS_GN_LABEL_H_
OLDNEW
« no previous file with comments | « net/dns/dns_hosts.h ('k') | tools/gn/label_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698