diff options
author | Brad King <brad.king@kitware.com> | 2020-03-26 13:15:02 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-03-26 13:15:41 (GMT) |
commit | 577fc3ef1942fd11791a4b6cd557b6da32daa5d6 (patch) | |
tree | 4ebc154a8be482113f395343df34adb208a238b1 /Source/cmcmd.cxx | |
parent | 607e790f4b627637a1884af4fc150afa0675c152 (diff) | |
parent | ec7928ef266599f1de08b30da84a42d7da3fd6a0 (diff) | |
download | CMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.zip CMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.tar.gz CMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.tar.bz2 |
Merge topic 'string-prefix'
ec7928ef26 use _s to construct static string_views at several places
94de927cab VS10Generator: avoid many string allocations
8ca2504a4d use string_views to avoid memory allocations
761f1adcae check for a valid URL scheme before starting to do any splitting
ef778d77e0 replace std::string::substr() with operations that do not allocate memory
77616f4681 pass cm::string_view to cmVisualStudioSlnParser::ParseTag()
ada6a3226f use cm::string_view for language extension lookups
48adc29721 replace "std::string::find(x) == 0" with cmHasPrefix()
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4501
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r-- | Source/cmcmd.cxx | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 7eeb97f..08543a9 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1054,8 +1054,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args) homeOutDir = args[5]; startOutDir = args[6]; depInfo = args[7]; - if (args.size() >= 9 && args[8].length() >= 8 && - args[8].substr(0, 8) == "--color=") { + if (args.size() >= 9 && cmHasLiteralPrefix(args[8], "--color=")) { // Enable or disable color based on the switch value. color = (args[8].size() == 8 || cmIsOn(args[8].substr(8))); } @@ -1304,7 +1303,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args) } else if (arg == "--debug") { pipe.clear(); isDebug = true; - } else if (arg.substr(0, pipePrefix.size()) == pipePrefix) { + } else if (cmHasPrefix(arg, pipePrefix)) { isDebug = false; pipe = arg.substr(pipePrefix.size()); if (pipe.empty()) { @@ -1511,7 +1510,7 @@ int cmcmd::ExecuteEchoColor(std::vector<std::string> const& args) bool newline = true; std::string progressDir; for (auto const& arg : cmMakeRange(args).advance(2)) { - if (arg.find("--switch=") == 0) { + if (cmHasLiteralPrefix(arg, "--switch=")) { // Enable or disable color based on the switch value. std::string value = arg.substr(9); if (!value.empty()) { @@ -1566,7 +1565,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string> const& args) // args[3] == --verbose=? bool verbose = false; if (args.size() >= 4) { - if (args[3].find("--verbose=") == 0) { + if (cmHasLiteralPrefix(args[3], "--verbose=")) { if (!cmIsOff(args[3].substr(10))) { verbose = true; } @@ -1826,7 +1825,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type) std::vector<std::string> expandedArgs; for (std::string const& i : args) { // check for nmake temporary files - if (i[0] == '@' && i.find("@CMakeFiles") != 0) { + if (i[0] == '@' && !cmHasLiteralPrefix(i, "@CMakeFiles")) { cmsys::ifstream fin(i.substr(1).c_str()); std::string line; while (cmSystemTools::GetLineFromStream(fin, line)) { |