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

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

Issue 1666843002: Refactor StringPiece hash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sort includes. Created 4 years, 10 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
« no previous file with comments | « net/tools/quic/spdy_balsa_utils.cc ('k') | ui/accessibility/ax_tree_update.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_SCOPE_H_ 5 #ifndef TOOLS_GN_SCOPE_H_
6 #define TOOLS_GN_SCOPE_H_ 6 #define TOOLS_GN_SCOPE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 // values resursively down the stack until a match is found or there are no 33 // values resursively down the stack until a match is found or there are no
34 // more containing scopes. 34 // more containing scopes.
35 // 35 //
36 // A containing scope can be const or non-const. The const containing scope is 36 // A containing scope can be const or non-const. The const containing scope is
37 // used primarily to refer to the master build config which is shared across 37 // used primarily to refer to the master build config which is shared across
38 // many invocations. A const containing scope, however, prevents us from 38 // many invocations. A const containing scope, however, prevents us from
39 // marking variables "used" which prevents us from issuing errors on unused 39 // marking variables "used" which prevents us from issuing errors on unused
40 // variables. So you should use a non-const containing scope whenever possible. 40 // variables. So you should use a non-const containing scope whenever possible.
41 class Scope { 41 class Scope {
42 public: 42 public:
43 typedef base::hash_map<base::StringPiece, Value> KeyValueMap; 43 typedef base::hash_map<base::StringPiece, Value, base::StringPieceHash>
44 KeyValueMap;
44 // Holds an owning list of Items. 45 // Holds an owning list of Items.
45 typedef ScopedVector<Item> ItemVector; 46 typedef ScopedVector<Item> ItemVector;
46 47
47 // Allows code to provide values for built-in variables. This class will 48 // Allows code to provide values for built-in variables. This class will
48 // automatically register itself on construction and deregister itself on 49 // automatically register itself on construction and deregister itself on
49 // destruction. 50 // destruction.
50 class ProgrammaticProvider { 51 class ProgrammaticProvider {
51 public: 52 public:
52 explicit ProgrammaticProvider(Scope* scope) : scope_(scope) { 53 explicit ProgrammaticProvider(Scope* scope) : scope_(scope) {
53 scope_->AddProvider(this); 54 scope_->AddProvider(this);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // change things (especially marking unused vars). 323 // change things (especially marking unused vars).
323 const Scope* const_containing_; 324 const Scope* const_containing_;
324 Scope* mutable_containing_; 325 Scope* mutable_containing_;
325 326
326 const Settings* settings_; 327 const Settings* settings_;
327 328
328 // Bits set for different modes. See the flag definitions in the .cc file 329 // Bits set for different modes. See the flag definitions in the .cc file
329 // for more. 330 // for more.
330 unsigned mode_flags_; 331 unsigned mode_flags_;
331 332
332 typedef base::hash_map<base::StringPiece, Record> RecordMap; 333 typedef base::hash_map<base::StringPiece, Record, base::StringPieceHash>
334 RecordMap;
333 RecordMap values_; 335 RecordMap values_;
334 336
335 // Owning pointers. Note that this can't use string pieces since the names 337 // Owning pointers. Note that this can't use string pieces since the names
336 // are constructed from Values which might be deallocated before this goes 338 // are constructed from Values which might be deallocated before this goes
337 // out of scope. 339 // out of scope.
338 typedef base::hash_map<std::string, Scope*> NamedScopeMap; 340 typedef base::hash_map<std::string, Scope*> NamedScopeMap;
339 NamedScopeMap target_defaults_; 341 NamedScopeMap target_defaults_;
340 342
341 // Null indicates not set and that we should fallback to the containing 343 // Null indicates not set and that we should fallback to the containing
342 // scope's filter. 344 // scope's filter.
(...skipping 11 matching lines...) Expand all
354 356
355 typedef std::set<ProgrammaticProvider*> ProviderSet; 357 typedef std::set<ProgrammaticProvider*> ProviderSet;
356 ProviderSet programmatic_providers_; 358 ProviderSet programmatic_providers_;
357 359
358 SourceDir source_dir_; 360 SourceDir source_dir_;
359 361
360 DISALLOW_COPY_AND_ASSIGN(Scope); 362 DISALLOW_COPY_AND_ASSIGN(Scope);
361 }; 363 };
362 364
363 #endif // TOOLS_GN_SCOPE_H_ 365 #endif // TOOLS_GN_SCOPE_H_
OLDNEW
« no previous file with comments | « net/tools/quic/spdy_balsa_utils.cc ('k') | ui/accessibility/ax_tree_update.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698