QCache: fix accidental pessimization
By unconditionally removing the existing entry we never hit the if (result.initialized) branch. Change it to only remove the existing entry if we don't plan on inserting. Task-number: QTBUG-88183 Change-Id: If4e7ebac23aa63d4b9d4b0a22882dd7d90a58e8b Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit f08492c6fd9818c7d80b1725355453e179b4d85b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9f0491b8c6
commit
7b2b4bb5d0
@ -236,10 +236,9 @@ public:
|
||||
|
||||
bool insert(const Key &key, T *object, qsizetype cost = 1)
|
||||
{
|
||||
remove(key);
|
||||
|
||||
if (cost > mx) {
|
||||
delete object;
|
||||
remove(key);
|
||||
return false;
|
||||
}
|
||||
trim(mx - cost);
|
||||
|
Loading…
x
Reference in New Issue
Block a user