From 1e738bcf9c7952bc9ae9bfb1be831c9f16998f54 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 13 Apr 2015 20:48:48 +0200 Subject: cmake: Simplify RemoveUnscriptableCommands algorithm. Remove obsolete RemoveCommand method. --- Source/cmake.cxx | 30 ++++++++---------------------- Source/cmake.h | 1 - 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 0dcf9be..b852e00 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -261,17 +261,6 @@ void cmake::RenameCommand(const std::string& oldName, this->Commands.erase(pos); } -void cmake::RemoveCommand(const std::string& name) -{ - std::string sName = cmSystemTools::LowerCase(name); - RegisteredCommandsMap::iterator pos = this->Commands.find(sName); - if ( pos != this->Commands.end() ) - { - delete pos->second; - this->Commands.erase(pos); - } -} - void cmake::AddCommand(cmCommand* command) { std::string name = cmSystemTools::LowerCase(command->GetName()); @@ -289,22 +278,19 @@ void cmake::AddCommand(cmCommand* command) void cmake::RemoveUnscriptableCommands() { std::vector unscriptableCommands; - for (cmake::RegisteredCommandsMap::const_iterator + for (cmake::RegisteredCommandsMap::iterator pos = this->Commands.begin(); - pos != this->Commands.end(); - ++pos) + pos != this->Commands.end(); ) { if (!pos->second->IsScriptable()) { - unscriptableCommands.push_back(pos->first); + delete pos->second; + this->Commands.erase(pos++); + } + else + { + ++pos; } - } - - for(std::vector::const_iterator it=unscriptableCommands.begin(); - it != unscriptableCommands.end(); - ++it) - { - this->RemoveCommand(*it); } } diff --git a/Source/cmake.h b/Source/cmake.h index 38c05c9..455b54e 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -222,7 +222,6 @@ class cmake */ void AddCommand(cmCommand* ); void RenameCommand(const std::string& oldName, const std::string& newName); - void RemoveCommand(const std::string& name); void RemoveUnscriptableCommands(); /** -- cgit v0.12