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 <thiago.macieira@intel.com>
This commit is contained in:
parent
6b59ff5730
commit
1461fbb5d1
@ -350,7 +350,7 @@ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat)
|
|||||||
void QLoggingRegistry::registerEnvironmentOverrideForCategory(const char *categoryName,
|
void QLoggingRegistry::registerEnvironmentOverrideForCategory(const char *categoryName,
|
||||||
const char *environment)
|
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())
|
if (it == reg->qtCategoryEnvironmentOverrides.end())
|
||||||
debug = false;
|
debug = false;
|
||||||
else
|
else
|
||||||
debug = qEnvironmentVariableIntValue(it.value());
|
debug = qEnvironmentVariableIntValue(it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,12 @@
|
|||||||
#include <QtCore/qloggingcategory.h>
|
#include <QtCore/qloggingcategory.h>
|
||||||
#include <QtCore/qlist.h>
|
#include <QtCore/qlist.h>
|
||||||
#include <QtCore/qhash.h>
|
#include <QtCore/qhash.h>
|
||||||
#include <QtCore/qmap.h>
|
|
||||||
#include <QtCore/qmutex.h>
|
#include <QtCore/qmutex.h>
|
||||||
#include <QtCore/qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
#include <QtCore/qtextstream.h>
|
#include <QtCore/qtextstream.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
class tst_QLoggingRegistry;
|
class tst_QLoggingRegistry;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -127,7 +128,7 @@ private:
|
|||||||
QList<QLoggingRule> ruleSets[NumRuleSets];
|
QList<QLoggingRule> ruleSets[NumRuleSets];
|
||||||
QHash<QLoggingCategory *, QtMsgType> categories;
|
QHash<QLoggingCategory *, QtMsgType> categories;
|
||||||
QLoggingCategory::CategoryFilter categoryFilter;
|
QLoggingCategory::CategoryFilter categoryFilter;
|
||||||
QMap<QByteArrayView, const char *> qtCategoryEnvironmentOverrides;
|
std::map<QByteArrayView, const char *> qtCategoryEnvironmentOverrides;
|
||||||
|
|
||||||
friend class ::tst_QLoggingRegistry;
|
friend class ::tst_QLoggingRegistry;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user