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 oldSize = categories.size();
|
||||
auto &e = categories[cat];
|
||||
if (categories.size() != oldSize) {
|
||||
auto r = categories.tryEmplace(cat, enableForLevel);
|
||||
if (r.inserted) {
|
||||
// new entry
|
||||
e = enableForLevel;
|
||||
(*categoryFilter)(cat);
|
||||
}
|
||||
}
|
||||
|
@ -1688,12 +1688,8 @@ public:
|
||||
bool insertIfNotContains(Key k, const T &f)
|
||||
{
|
||||
const QWriteLocker locker(&lock);
|
||||
const qsizetype oldSize = map.size();
|
||||
auto &e = map[k];
|
||||
if (map.size() == oldSize) // already present
|
||||
return false;
|
||||
e = f;
|
||||
return true;
|
||||
auto r = map.tryEmplace(k, f);
|
||||
return r.inserted;
|
||||
}
|
||||
|
||||
const T *function(Key k) const
|
||||
|
Loading…
x
Reference in New Issue
Block a user