Skip to content

Commit 2ab68f0

Browse files
mplekhGabrielcarvfer
authored andcommitted
log: Inline LogComponent::IsEnabled() method for performance
1 parent 00f7415 commit 2ab68f0

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/core/model/log.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,6 @@ LogComponent::EnvVarCheck()
232232
Enable((LogLevel)level);
233233
}
234234

235-
bool
236-
LogComponent::IsEnabled(const LogLevel level) const
237-
{
238-
// LogComponentEnableEnvVar ();
239-
return level & m_levels;
240-
}
241-
242235
bool
243236
LogComponent::IsNoneEnabled() const
244237
{

src/core/model/log.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,22 @@ class LogComponent
326326
* functions which help implement the logging facility.
327327
*/
328328
LogComponent(const std::string& name, const std::string& file, const LogLevel mask = LOG_NONE);
329+
329330
/**
330331
* Check if this LogComponent is enabled for \c level
331332
*
332333
* @param [in] level The level to check for.
333334
* @return \c true if we are enabled at \c level.
335+
*
336+
* @internal
337+
* This function is defined in the header to enable inlining for better performance. See:
338+
* https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/2448#note_2527898962
334339
*/
335-
bool IsEnabled(const LogLevel level) const;
340+
bool IsEnabled(const LogLevel level) const
341+
{
342+
return level & m_levels;
343+
}
344+
336345
/**
337346
* Check if all levels are disabled.
338347
*

0 commit comments

Comments
 (0)