From 1461fbb5d183e8894ad1a097c147dce21656bd01 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 7 Feb 2024 11:56:38 +0100 Subject: [PATCH] QLoggingRegistry: cut out the QMap middle-man In Qt 6, QMap is just a shared pointer to a std::map. QLoggingRegistry::qtCategoryEnvironmentOverrides is never copied, though, so the implicit sharing that QMap adds on top of std::map is useless. Use the underlying std::map directly. Yes, the std::map API is a bit raw around the edges (std::pair value_type), but we're professionals here. This saves more than 1.1KiB in TEXT size on optimized AMD64 GCC 11 C++20 Linux builds. Change-Id: Id72b2432ed41a97700cc2d9ecafa902b919efe84 Reviewed-by: Thiago Macieira --- src/corelib/io/qloggingregistry.cpp | 4 ++-- src/corelib/io/qloggingregistry_p.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index f9728f9b72d..8c9216ff62d 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -350,7 +350,7 @@ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat) void QLoggingRegistry::registerEnvironmentOverrideForCategory(const char *categoryName, const char *environment) { - qtCategoryEnvironmentOverrides.insert(categoryName, environment); + qtCategoryEnvironmentOverrides.insert_or_assign(categoryName, environment); } /*! @@ -442,7 +442,7 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat) if (it == reg->qtCategoryEnvironmentOverrides.end()) debug = false; else - debug = qEnvironmentVariableIntValue(it.value()); + debug = qEnvironmentVariableIntValue(it->second); } } diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index aa38ed895be..0c378499f32 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -19,11 +19,12 @@ #include #include #include -#include #include #include #include +#include + class tst_QLoggingRegistry; QT_BEGIN_NAMESPACE @@ -127,7 +128,7 @@ private: QList ruleSets[NumRuleSets]; QHash categories; QLoggingCategory::CategoryFilter categoryFilter; - QMap qtCategoryEnvironmentOverrides; + std::map qtCategoryEnvironmentOverrides; friend class ::tst_QLoggingRegistry; };