summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-05-10 09:22:38 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-05-10 18:22:26 (GMT)
commit02293841e742c14a18155bc0e10c39462c97dcbf (patch)
tree770fb507ae356ce086ef5eb37df0ab88058165d9 /Source/cmGlobalNinjaGenerator.cxx
parenta173a1173e06dad812afe17c9751cb7c2f94eda4 (diff)
downloadCMake-02293841e742c14a18155bc0e10c39462c97dcbf.zip
CMake-02293841e742c14a18155bc0e10c39462c97dcbf.tar.gz
CMake-02293841e742c14a18155bc0e10c39462c97dcbf.tar.bz2
Ninja: Simplify cmGlobalNinjaGenerator::AddRule and HasRule methods
- Use `std::unordered_set` for the emitted rule register - Use `std::unordered_map` for command length register
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx12
1 files changed, 5 insertions, 7 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 06234aa..684a679 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -706,22 +706,20 @@ void cmGlobalNinjaGenerator::AddRule(
const std::string& restat, bool generator)
{
// Do not add the same rule twice.
- if (this->HasRule(name)) {
+ if (!this->Rules.insert(name).second) {
return;
}
-
- this->Rules.insert(name);
+ // Store command length
+ this->RuleCmdLength[name] = static_cast<int>(command.size());
+ // Write rule
cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream, name, command,
description, comment, depfile, deptype,
rspfile, rspcontent, restat, generator);
-
- this->RuleCmdLength[name] = static_cast<int>(command.size());
}
bool cmGlobalNinjaGenerator::HasRule(const std::string& name)
{
- RulesSetType::const_iterator rule = this->Rules.find(name);
- return (rule != this->Rules.end());
+ return (this->Rules.find(name) != this->Rules.end());
}
// Private virtual overrides