aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-20 00:07:40 +0000
committerChris Lattner <sabre@nondot.org>2009-09-20 00:07:40 +0000
commitba11229f52743ac70f01d4f62d1e04dd093de4e0 (patch)
tree658c92aa60eda8c6d423897ef5d50d6f63c1d5e1 /lib/Support/CommandLine.cpp
parentf4d18827430be9ac3a7a5216be61224146d97f44 (diff)
avoid a bunch of malloc thrashing for PositinoalVals by eliminating
a std::vector and a bunch of std::string temporaries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82341 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CommandLine.cpp')
-rw-r--r--lib/Support/CommandLine.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index 445fcc7886..1d0b9acc4b 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -181,17 +181,16 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
switch (Handler->getValueExpectedFlag()) {
case ValueRequired:
if (Value == 0) { // No value specified?
- if (i+1 < argc) { // Steal the next argument, like for '-o filename'
- Value = argv[++i];
- } else {
+ if (i+1 >= argc)
return Handler->error("requires a value!");
- }
+ // Steal the next argument, like for '-o filename'
+ Value = argv[++i];
}
break;
case ValueDisallowed:
if (NumAdditionalVals > 0)
return Handler->error("multi-valued option specified"
- " with ValueDisallowed modifier!");
+ " with ValueDisallowed modifier!");
if (Value)
return Handler->error("does not allow a value! '" +
@@ -199,6 +198,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
break;
case ValueOptional:
break;
+
default:
errs() << ProgramName
<< ": Bad ValueMask flag! CommandLine usage error:"
@@ -221,7 +221,6 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
}
while (NumAdditionalVals > 0) {
-
if (i+1 >= argc)
return Handler->error("not enough values!");
Value = argv[++i];
@@ -234,10 +233,9 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
return false;
}
-static bool ProvidePositionalOption(Option *Handler, const std::string &Arg,
- int i) {
+static bool ProvidePositionalOption(Option *Handler, StringRef Arg, int i) {
int Dummy = i;
- return ProvideOption(Handler, Handler->ArgStr, Arg.c_str(), 0, 0, Dummy);
+ return ProvideOption(Handler, Handler->ArgStr, Arg.data(), 0, 0, Dummy);
}
@@ -483,9 +481,9 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
}
// PositionalVals - A vector of "positional" arguments we accumulate into
- // the process at the end...
+ // the process at the end.
//
- std::vector<std::pair<std::string,unsigned> > PositionalVals;
+ SmallVector<std::pair<StringRef,unsigned>, 4> PositionalVals;
// If the program has named positional arguments, and the name has been run
// across, keep track of which positional argument was named. Otherwise put