diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-04-13 20:25:55 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-04-13 20:25:55 (GMT) |
commit | c09f6172a4556aed7e84492497986f63e3192e14 (patch) | |
tree | 5505b8b9ff3568f4b64bb4c4aef2a1b757f21e6d /Source/cmSystemTools.cxx | |
parent | 5e02b5ec961bc6dd5ce73df2d0cfd5c8c0524f90 (diff) | |
download | CMake-c09f6172a4556aed7e84492497986f63e3192e14.zip CMake-c09f6172a4556aed7e84492497986f63e3192e14.tar.gz CMake-c09f6172a4556aed7e84492497986f63e3192e14.tar.bz2 |
ENH: Improve performance by using vector of char instead of string
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index f9890f4..5f44543 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -952,7 +952,6 @@ void cmSystemTools::ExpandList(std::vector<std::string> const& arguments, void cmSystemTools::ExpandListArgument(const std::string& arg, std::vector<std::string>& newargs) { - std::string newarg; // If argument is empty, it is an empty list. if(arg.length() == 0) { @@ -964,6 +963,7 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, newargs.push_back(arg); return; } + std::vector<char> newArgVec; // Break the string at non-escaped semicolons not nested in []. int squareNesting = 0; for(const char* c = arg.c_str(); *c; ++c) @@ -977,26 +977,26 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, ++c; if(*c == ';') { - newarg += ';'; + newArgVec.push_back(*c); } else { - newarg += '\\'; + newArgVec.push_back('\\'); if(*c) { - newarg += *c; + newArgVec.push_back(*c); } } } break; case '[': { ++squareNesting; - newarg += '['; + newArgVec.push_back(*c); } break; case ']': { --squareNesting; - newarg += ']'; + newArgVec.push_back(*c); } break; case ';': { @@ -1004,29 +1004,31 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, // brackets. if(squareNesting == 0) { - if(newarg.length()) + if ( newArgVec.size() ) { - // Add an argument if the string is not empty. - newargs.push_back(newarg); - newarg = ""; + // Add the last argument if the string is not empty. + newArgVec.push_back(0); + newargs.push_back(&*newArgVec.begin()); + newArgVec.clear(); } } else { - newarg += ';'; + newArgVec.push_back(*c); } } break; default: { // Just append this character. - newarg += *c; + newArgVec.push_back(*c); } break; } } - if(newarg.length()) + if ( newArgVec.size() ) { // Add the last argument if the string is not empty. - newargs.push_back(newarg); + newArgVec.push_back(0); + newargs.push_back(&*newArgVec.begin()); } } |