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

Side by Side Diff: base/command_line.h

Issue 1007283012: Provide CommandLine::HasSwitch(const char*) to save 76kB in sizes perf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skip the case optimization Created 5 years, 9 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 | « no previous file | base/command_line.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This class works with command lines: building and parsing. 5 // This class works with command lines: building and parsing.
6 // Arguments with prefixes ('--', '-', and on Windows, '/') are switches. 6 // Arguments with prefixes ('--', '-', and on Windows, '/') are switches.
7 // Switches will precede all other arguments without switch prefixes. 7 // Switches will precede all other arguments without switch prefixes.
8 // Switches can optionally have values, delimited by '=', e.g., "-switch=value". 8 // Switches can optionally have values, delimited by '=', e.g., "-switch=value".
9 // An argument of "--" will terminate switch parsing during initialization, 9 // An argument of "--" will terminate switch parsing during initialization,
10 // interpreting subsequent tokens as non-switch arguments, regardless of prefix. 10 // interpreting subsequent tokens as non-switch arguments, regardless of prefix.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 #endif 135 #endif
136 136
137 // Returns the original command line string as a vector of strings. 137 // Returns the original command line string as a vector of strings.
138 const StringVector& argv() const { return argv_; } 138 const StringVector& argv() const { return argv_; }
139 139
140 // Get and Set the program part of the command line string (the first item). 140 // Get and Set the program part of the command line string (the first item).
141 FilePath GetProgram() const; 141 FilePath GetProgram() const;
142 void SetProgram(const FilePath& program); 142 void SetProgram(const FilePath& program);
143 143
144 // Returns true if this command line contains the given switch. 144 // Returns true if this command line contains the given switch.
145 // (Switch names are case-insensitive). 145 // (Switch names are case-insensitive).
tapted 2015/03/18 08:51:45 This comment isn't really true except on Windows..
146 // The second override provides an optimized version to avoid inlining the
147 // codegen for the string allocation.
146 bool HasSwitch(const std::string& switch_string) const; 148 bool HasSwitch(const std::string& switch_string) const;
149 bool HasSwitch(const char switch_constant[]) const;
147 150
148 // Returns the value associated with the given switch. If the switch has no 151 // Returns the value associated with the given switch. If the switch has no
149 // value or isn't present, this method returns the empty string. 152 // value or isn't present, this method returns the empty string.
150 std::string GetSwitchValueASCII(const std::string& switch_string) const; 153 std::string GetSwitchValueASCII(const std::string& switch_string) const;
151 FilePath GetSwitchValuePath(const std::string& switch_string) const; 154 FilePath GetSwitchValuePath(const std::string& switch_string) const;
152 StringType GetSwitchValueNative(const std::string& switch_string) const; 155 StringType GetSwitchValueNative(const std::string& switch_string) const;
153 156
154 // Get a copy of all switches, along with their values. 157 // Get a copy of all switches, along with their values.
155 const SwitchMap& GetSwitches() const { return switches_; } 158 const SwitchMap& GetSwitches() const { return switches_; }
156 159
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Parsed-out switch keys and values. 223 // Parsed-out switch keys and values.
221 SwitchMap switches_; 224 SwitchMap switches_;
222 225
223 // The index after the program and switches, any arguments start here. 226 // The index after the program and switches, any arguments start here.
224 size_t begin_args_; 227 size_t begin_args_;
225 }; 228 };
226 229
227 } // namespace base 230 } // namespace base
228 231
229 #endif // BASE_COMMAND_LINE_H_ 232 #endif // BASE_COMMAND_LINE_H_
OLDNEW
« no previous file with comments | « no previous file | base/command_line.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698