summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-05-19 19:05:43 +0200
committerThomas Haller <thaller@redhat.com>2016-05-19 19:51:31 +0200
commit6dfad411ca7e2326b7b169c3635eff67c83bed1b (patch)
treebf723bc5617493ab22c1dfb6be1fa822cf3d2a86
parent32133a0c51041ed8245291bd2fb10975649e416a (diff)
downloadNetworkManager-th/logging-inline-enabled.tar.gz
logging: make nm_logging_enabled() inline functionth/logging-inline-enabled
Basically every logging statement is wrapped by a nm_logging_enabled() to evaluate the function call of the logging lazy. Make the function a candidate for inlining, it safes some space. On a default build it goes for me from 2580584 to 2560104 bytes (20k). $ ./autogen.sh && make && strip ./src/NetworkManager
-rw-r--r--src/nm-logging.c10
-rw-r--r--src/nm-logging.h9
2 files changed, 9 insertions, 10 deletions
diff --git a/src/nm-logging.c b/src/nm-logging.c
index 39166efa5f..4e64a587e4 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -98,7 +98,7 @@ typedef struct {
LogFormatFlags log_format_level;
} LogLevelDesc;
-static NMLogDomain _nm_logging_enabled_state[_LOGL_N_REAL] = {
+NMLogDomain _nm_logging_enabled_state[_LOGL_N_REAL] = {
/* nm_logging_setup ("INFO", LOGD_DEFAULT_STRING, NULL, NULL); */
[LOGL_INFO] = LOGD_DEVICE,
[LOGL_WARN] = LOGD_DEVICE,
@@ -445,14 +445,6 @@ nm_logging_all_domains_to_string (void)
return str->str;
}
-gboolean
-nm_logging_enabled (NMLogLevel level, NMLogDomain domain)
-{
- nm_assert (((guint) level) < G_N_ELEMENTS (_nm_logging_enabled_state));
-
- return !!(_nm_logging_enabled_state[level] & domain);
-}
-
#if SYSTEMD_JOURNAL
__attribute__((__format__ (__printf__, 4, 5)))
static void
diff --git a/src/nm-logging.h b/src/nm-logging.h
index 27f89f5d5b..c134670501 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -158,7 +158,14 @@ void _nm_log_impl (const char *file,
const char *nm_logging_level_to_string (void);
const char *nm_logging_domains_to_string (void);
-gboolean nm_logging_enabled (NMLogLevel level, NMLogDomain domain);
+
+extern NMLogDomain _nm_logging_enabled_state[_LOGL_N_REAL];
+static inline gboolean
+nm_logging_enabled (NMLogLevel level, NMLogDomain domain)
+{
+ nm_assert (((guint) level) < G_N_ELEMENTS (_nm_logging_enabled_state));
+ return !!(_nm_logging_enabled_state[level] & domain);
+}
const char *nm_logging_all_levels_to_string (void);
const char *nm_logging_all_domains_to_string (void);