diff options
author | Meekness Adesina <zenon8adams@gmail.com> | 2023-05-18 21:11:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-05-19 13:56:07 (GMT) |
commit | 8c066045ec02cdfc7396a20b842838ae87610512 (patch) | |
tree | 2cf7e57385479bcb24951623136363ff328417d0 /Source/cmMessenger.cxx | |
parent | f64a774b49baaba40056edd8c5f8eb97292dd7d0 (diff) | |
download | CMake-8c066045ec02cdfc7396a20b842838ae87610512.zip CMake-8c066045ec02cdfc7396a20b842838ae87610512.tar.gz CMake-8c066045ec02cdfc7396a20b842838ae87610512.tar.bz2 |
Source: Improve some code readability and efficiency
- Replace raw loop with STL find algorithm for improved efficiency
- Update functions for enhanced readability and understandability
Diffstat (limited to 'Source/cmMessenger.cxx')
-rw-r--r-- | Source/cmMessenger.cxx | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx index ff513be..7de8936 100644 --- a/Source/cmMessenger.cxx +++ b/Source/cmMessenger.cxx @@ -18,51 +18,38 @@ MessageType cmMessenger::ConvertMessageType(MessageType t) const { - bool warningsAsErrors; - if (t == MessageType::AUTHOR_WARNING || t == MessageType::AUTHOR_ERROR) { - warningsAsErrors = this->GetDevWarningsAsErrors(); - if (warningsAsErrors && t == MessageType::AUTHOR_WARNING) { - t = MessageType::AUTHOR_ERROR; - } else if (!warningsAsErrors && t == MessageType::AUTHOR_ERROR) { - t = MessageType::AUTHOR_WARNING; + if (this->GetDevWarningsAsErrors()) { + return MessageType::AUTHOR_ERROR; } - } else if (t == MessageType::DEPRECATION_WARNING || - t == MessageType::DEPRECATION_ERROR) { - warningsAsErrors = this->GetDeprecatedWarningsAsErrors(); - if (warningsAsErrors && t == MessageType::DEPRECATION_WARNING) { - t = MessageType::DEPRECATION_ERROR; - } else if (!warningsAsErrors && t == MessageType::DEPRECATION_ERROR) { - t = MessageType::DEPRECATION_WARNING; + return MessageType::AUTHOR_WARNING; + } + if (t == MessageType::DEPRECATION_WARNING || + t == MessageType::DEPRECATION_ERROR) { + if (this->GetDeprecatedWarningsAsErrors()) { + return MessageType::DEPRECATION_ERROR; } + return MessageType::DEPRECATION_WARNING; } - return t; } bool cmMessenger::IsMessageTypeVisible(MessageType t) const { - bool isVisible = true; - if (t == MessageType::DEPRECATION_ERROR) { - if (!this->GetDeprecatedWarningsAsErrors()) { - isVisible = false; - } - } else if (t == MessageType::DEPRECATION_WARNING) { - if (this->GetSuppressDeprecatedWarnings()) { - isVisible = false; - } - } else if (t == MessageType::AUTHOR_ERROR) { - if (!this->GetDevWarningsAsErrors()) { - isVisible = false; - } - } else if (t == MessageType::AUTHOR_WARNING) { - if (this->GetSuppressDevWarnings()) { - isVisible = false; - } + return this->GetDeprecatedWarningsAsErrors(); + } + if (t == MessageType::DEPRECATION_WARNING) { + return !this->GetSuppressDeprecatedWarnings(); + } + if (t == MessageType::AUTHOR_ERROR) { + return this->GetDevWarningsAsErrors(); + } + if (t == MessageType::AUTHOR_WARNING) { + return !this->GetSuppressDevWarnings(); } - return isVisible; + return true; } static bool printMessagePreamble(MessageType t, std::ostream& msg) |