diff options
author | Cengizhan Pasaoglu <cengizhanpasaoglu@gmail.com> | 2018-11-06 09:47:40 +0300 |
---|---|---|
committer | Cengizhan Pasaoglu <cengizhanpasaoglu@gmail.com> | 2018-11-06 21:43:33 +0300 |
commit | c67ab22cdc680f6322e558b4f2c7cc74b6dbe163 (patch) | |
tree | 7197d12da074c751ad482f8dd9ed009a5f290198 /Source/cmStringCommand.cxx | |
parent | bfdd1ba604a31b3bb9f0baa29ce6fce467ee2e47 (diff) | |
download | cmake-c67ab22cdc680f6322e558b4f2c7cc74b6dbe163.tar.gz |
Using front() and back() instead of calculations
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r-- | Source/cmStringCommand.cxx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 1605fd7bc7..91d6190207 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -156,7 +156,7 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args) return false; } std::string::size_type cc; - std::string const& outvar = args[args.size() - 1]; + std::string const& outvar = args.back(); std::string output; for (cc = 1; cc < args.size() - 1; cc++) { int ch = atoi(args[cc].c_str()); @@ -755,7 +755,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args) this->SetError("sub-command RANDOM invoked with bad length."); return false; } - const std::string& variableName = args[args.size() - 1]; + const std::string& variableName = args.back(); std::vector<char> result; @@ -765,8 +765,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args) } const char* alphaPtr = alphabet.c_str(); - int cc; - for (cc = 0; cc < length; cc++) { + for (int cc = 0; cc < length; cc++) { int idx = static_cast<int>(sizeofAlphabet * rand() / (RAND_MAX + 1.0)); result.push_back(*(alphaPtr + idx)); } |