mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
avoid a bunch of malloc thrashing for PositinoalVals by eliminating
a std::vector and a bunch of std::string temporaries. llvm-svn: 82341
This commit is contained in:
parent
6ad3b51864
commit
bb111eeae4
@ -181,17 +181,16 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
switch (Handler->getValueExpectedFlag()) {
|
switch (Handler->getValueExpectedFlag()) {
|
||||||
case ValueRequired:
|
case ValueRequired:
|
||||||
if (Value == 0) { // No value specified?
|
if (Value == 0) { // No value specified?
|
||||||
if (i+1 < argc) { // Steal the next argument, like for '-o filename'
|
if (i+1 >= argc)
|
||||||
Value = argv[++i];
|
|
||||||
} else {
|
|
||||||
return Handler->error("requires a value!");
|
return Handler->error("requires a value!");
|
||||||
}
|
// Steal the next argument, like for '-o filename'
|
||||||
|
Value = argv[++i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ValueDisallowed:
|
case ValueDisallowed:
|
||||||
if (NumAdditionalVals > 0)
|
if (NumAdditionalVals > 0)
|
||||||
return Handler->error("multi-valued option specified"
|
return Handler->error("multi-valued option specified"
|
||||||
" with ValueDisallowed modifier!");
|
" with ValueDisallowed modifier!");
|
||||||
|
|
||||||
if (Value)
|
if (Value)
|
||||||
return Handler->error("does not allow a value! '" +
|
return Handler->error("does not allow a value! '" +
|
||||||
@ -199,6 +198,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
break;
|
break;
|
||||||
case ValueOptional:
|
case ValueOptional:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errs() << ProgramName
|
errs() << ProgramName
|
||||||
<< ": Bad ValueMask flag! CommandLine usage error:"
|
<< ": Bad ValueMask flag! CommandLine usage error:"
|
||||||
@ -221,7 +221,6 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (NumAdditionalVals > 0) {
|
while (NumAdditionalVals > 0) {
|
||||||
|
|
||||||
if (i+1 >= argc)
|
if (i+1 >= argc)
|
||||||
return Handler->error("not enough values!");
|
return Handler->error("not enough values!");
|
||||||
Value = argv[++i];
|
Value = argv[++i];
|
||||||
@ -234,10 +233,9 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ProvidePositionalOption(Option *Handler, const std::string &Arg,
|
static bool ProvidePositionalOption(Option *Handler, StringRef Arg, int i) {
|
||||||
int i) {
|
|
||||||
int Dummy = 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
|
// 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
|
// If the program has named positional arguments, and the name has been run
|
||||||
// across, keep track of which positional argument was named. Otherwise put
|
// across, keep track of which positional argument was named. Otherwise put
|
||||||
|
Loading…
Reference in New Issue
Block a user