Use QHash::tryEmplace
Instead of size != oldSize pattern. Just some locations I could find using a simple regex lookup. Task-number: QTBUG-130259 Change-Id: I0ac6a4faf8705ce54cb8dd875ee5524ef13f03dc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
6a5e2c6f9b
commit
370031f809
@ -337,11 +337,9 @@ void QLoggingRegistry::registerCategory(QLoggingCategory *cat, QtMsgType enableF
|
|||||||
{
|
{
|
||||||
const auto locker = qt_scoped_lock(registryMutex);
|
const auto locker = qt_scoped_lock(registryMutex);
|
||||||
|
|
||||||
const auto oldSize = categories.size();
|
auto r = categories.tryEmplace(cat, enableForLevel);
|
||||||
auto &e = categories[cat];
|
if (r.inserted) {
|
||||||
if (categories.size() != oldSize) {
|
|
||||||
// new entry
|
// new entry
|
||||||
e = enableForLevel;
|
|
||||||
(*categoryFilter)(cat);
|
(*categoryFilter)(cat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1688,12 +1688,8 @@ public:
|
|||||||
bool insertIfNotContains(Key k, const T &f)
|
bool insertIfNotContains(Key k, const T &f)
|
||||||
{
|
{
|
||||||
const QWriteLocker locker(&lock);
|
const QWriteLocker locker(&lock);
|
||||||
const qsizetype oldSize = map.size();
|
auto r = map.tryEmplace(k, f);
|
||||||
auto &e = map[k];
|
return r.inserted;
|
||||||
if (map.size() == oldSize) // already present
|
|
||||||
return false;
|
|
||||||
e = f;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const T *function(Key k) const
|
const T *function(Key k) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user