diff options
author | tapted <tapted@chromium.org> | 2015-03-29 20:57:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-30 03:57:42 +0000 |
commit | 009a1dc860942184fc6abdb4bedf854b15da7d91 (patch) | |
tree | 16612c10f058edf08e57d6aa2da5cf510f99caa9 /base/command_line.cc | |
parent | 6983a3f9c5b228716e6b6ee1c477cfa1a42472a4 (diff) | |
download | chromium_src-009a1dc860942184fc6abdb4bedf854b15da7d91.zip chromium_src-009a1dc860942184fc6abdb4bedf854b15da7d91.tar.gz chromium_src-009a1dc860942184fc6abdb4bedf854b15da7d91.tar.bz2 |
Provide CommandLine::HasSwitch(const char*) to save 76kB in sizes perf
Currently every callsite to CommandLine::HasSwitch() has to generate
code to allocate a string on the stack, malloc(), copy characters from
the switch constant, and then free things when it goes out of scope.
Testing on a Mac release build, this results in about 76kB of generated
object code. (about 40 bytes for each of the ~1928 calls in the non-test
codebase).
Adding a char[] overload allows this codegen to happen only once. And
there's no lost inlining benefit since the new overload can inline its
call instead.
BUG=468184
Review URL: https://codereview.chromium.org/1007283012
Cr-Commit-Position: refs/heads/master@{#322737}
Diffstat (limited to 'base/command_line.cc')
-rw-r--r-- | base/command_line.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/base/command_line.cc b/base/command_line.cc index d28a4b4..3e143cc 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -266,6 +266,10 @@ bool CommandLine::HasSwitch(const std::string& switch_string) const { return switches_.find(LowerASCIIOnWindows(switch_string)) != switches_.end(); } +bool CommandLine::HasSwitch(const char string_constant[]) const { + return HasSwitch(std::string(string_constant)); +} + std::string CommandLine::GetSwitchValueASCII( const std::string& switch_string) const { StringType value = GetSwitchValueNative(switch_string); |