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

Side by Side Diff: base/command_line.cc

Issue 815543002: Avoid a string copy for every CommandLine::HasSwitch query (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo line removal Created 6 years 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 | no next file » | 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 #include "base/command_line.h" 5 #include "base/command_line.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 #elif defined(OS_POSIX) 87 #elif defined(OS_POSIX)
88 command_line->AppendSwitchNative(switch_string, switch_value); 88 command_line->AppendSwitchNative(switch_string, switch_value);
89 #endif 89 #endif
90 } else { 90 } else {
91 command_line->AppendArgNative(arg); 91 command_line->AppendArgNative(arg);
92 } 92 }
93 } 93 }
94 } 94 }
95 95
96 // Lowercase switches for backwards compatiblity *on Windows*. 96 // Lowercase switches for backwards compatiblity *on Windows*.
97 #if defined(OS_WIN)
97 std::string LowerASCIIOnWindows(const std::string& string) { 98 std::string LowerASCIIOnWindows(const std::string& string) {
98 #if defined(OS_WIN)
99 return StringToLowerASCII(string); 99 return StringToLowerASCII(string);
100 }
100 #elif defined(OS_POSIX) 101 #elif defined(OS_POSIX)
102 const std::string& LowerASCIIOnWindows(const std::string& string) {
101 return string; 103 return string;
104 }
102 #endif 105 #endif
103 }
104 106
105 107
106 #if defined(OS_WIN) 108 #if defined(OS_WIN)
107 // Quote a string as necessary for CommandLineToArgvW compatiblity *on Windows*. 109 // Quote a string as necessary for CommandLineToArgvW compatiblity *on Windows*.
108 string16 QuoteForCommandLineToArgvW(const string16& arg, 110 string16 QuoteForCommandLineToArgvW(const string16& arg,
109 bool quote_placeholders) { 111 bool quote_placeholders) {
110 // We follow the quoting rules of CommandLineToArgvW. 112 // We follow the quoting rules of CommandLineToArgvW.
111 // http://msdn.microsoft.com/en-us/library/17w5ykft.aspx 113 // http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
112 string16 quotable_chars(L" \\\""); 114 string16 quotable_chars(L" \\\"");
113 // We may also be required to quote '%', which is commonly used in a command 115 // We may also be required to quote '%', which is commonly used in a command
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 #if defined(OS_WIN) 442 #if defined(OS_WIN)
441 arg = QuoteForCommandLineToArgvW(arg, quote_placeholders); 443 arg = QuoteForCommandLineToArgvW(arg, quote_placeholders);
442 #endif 444 #endif
443 params.append(arg); 445 params.append(arg);
444 } 446 }
445 } 447 }
446 return params; 448 return params;
447 } 449 }
448 450
449 } // namespace base 451 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698