diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2018-07-25 10:08:19 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2018-07-25 10:08:19 (GMT) |
commit | d1077c1ce6310f02c93962cbb89e82dc57a6dd31 (patch) | |
tree | fcb69a8ec9fed1d593873097c80a130c528b7719 /Source/cmLocalGenerator.cxx | |
parent | 873f40ecec50fbe6c8e98a0764c02a423dbfa05b (diff) | |
download | CMake-d1077c1ce6310f02c93962cbb89e82dc57a6dd31.zip CMake-d1077c1ce6310f02c93962cbb89e82dc57a6dd31.tar.gz CMake-d1077c1ce6310f02c93962cbb89e82dc57a6dd31.tar.bz2 |
cmLocalGenerator: Style change: Use return value of std::set::insert
Code style change in ``cmLocalGenerator::GetIncludeDirectories()``.
Use the return value of ``std::set::insert`` instead of testing
if the entry already exists in the set using ``std::find``.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 072b958..f0db28d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -846,10 +846,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, const std::string& config, bool stripImplicitInclDirs) const { - // Need to decide whether to automatically include the source and - // binary directories at the beginning of the include path. - bool includeSourceDir = false; - bool includeBinaryDir = false; + // Do not repeat an include path. + std::set<std::string> emitted; // When automatic include directories are requested for a build then // include the source and binary directories at the beginning of the @@ -859,26 +857,21 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, // cannot fix this because not all native build tools support // per-source-file include paths. if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR")) { - includeSourceDir = true; - includeBinaryDir = true; - } - - // Do not repeat an include path. - std::set<std::string> emitted; - - // Store the automatic include paths. - if (includeBinaryDir) { - std::string binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary(); - if (emitted.find(binDir) == emitted.end()) { - dirs.push_back(binDir); - emitted.insert(binDir); + // Current binary directory + { + std::string binDir = + this->StateSnapshot.GetDirectory().GetCurrentBinary(); + if (emitted.insert(binDir).second) { + dirs.push_back(std::move(binDir)); + } } - } - if (includeSourceDir) { - std::string srcDir = this->StateSnapshot.GetDirectory().GetCurrentSource(); - if (emitted.find(srcDir) == emitted.end()) { - dirs.push_back(srcDir); - emitted.insert(srcDir); + // Current source directory + { + std::string srcDir = + this->StateSnapshot.GetDirectory().GetCurrentSource(); + if (emitted.insert(srcDir).second) { + dirs.push_back(std::move(srcDir)); + } } } |