0

Avoid a string copy for every CommandLine::HasSwitch query

Windows performs a lower-case conversion of all strings passed to
CommandLine::HasSwitch. Other platforms require no such conversion,
however, currently they pay for an associated string copy on each query.
Why? Because compilers aren't as smart as they should be. Remove this
string copy for non-Windows platforms. A string copy saved is a string
copy earned.

BUG=405348

Review URL: https://codereview.chromium.org/815543002

Cr-Commit-Position: refs/heads/master@{#308839}
This commit is contained in:
jdduke
2014-12-17 11:35:18 -08:00
committed by Commit bot
parent ef70294806
commit 034cff8362

@@ -94,13 +94,15 @@ void AppendSwitchesAndArguments(CommandLine* command_line,
}
// Lowercase switches for backwards compatiblity *on Windows*.
std::string LowerASCIIOnWindows(const std::string& string) {
#if defined(OS_WIN)
std::string LowerASCIIOnWindows(const std::string& string) {
return StringToLowerASCII(string);
#elif defined(OS_POSIX)
return string;
#endif
}
#elif defined(OS_POSIX)
const std::string& LowerASCIIOnWindows(const std::string& string) {
return string;
}
#endif
#if defined(OS_WIN)