From 2ab68f0cb62fa0b4e5b62767b35077664bcbcdf0 Mon Sep 17 00:00:00 2001 From: Max Plekh Date: Wed, 11 Jun 2025 16:09:50 +0300 Subject: [PATCH] log: Inline LogComponent::IsEnabled() method for performance --- src/core/model/log.cc | 7 ------- src/core/model/log.h | 11 ++++++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/model/log.cc b/src/core/model/log.cc index 9dd2c047b..54c9942ec 100644 --- a/src/core/model/log.cc +++ b/src/core/model/log.cc @@ -232,13 +232,6 @@ LogComponent::EnvVarCheck() Enable((LogLevel)level); } -bool -LogComponent::IsEnabled(const LogLevel level) const -{ - // LogComponentEnableEnvVar (); - return level & m_levels; -} - bool LogComponent::IsNoneEnabled() const { diff --git a/src/core/model/log.h b/src/core/model/log.h index cd8f397f5..39792ee70 100644 --- a/src/core/model/log.h +++ b/src/core/model/log.h @@ -326,13 +326,22 @@ class LogComponent * functions which help implement the logging facility. */ LogComponent(const std::string& name, const std::string& file, const LogLevel mask = LOG_NONE); + /** * Check if this LogComponent is enabled for \c level * * @param [in] level The level to check for. * @return \c true if we are enabled at \c level. + * + * @internal + * This function is defined in the header to enable inlining for better performance. See: + * https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/2448#note_2527898962 */ - bool IsEnabled(const LogLevel level) const; + bool IsEnabled(const LogLevel level) const + { + return level & m_levels; + } + /** * Check if all levels are disabled. *