Skip to content

Commit

Permalink
QCache: fix accidental pessimization
Browse files Browse the repository at this point in the history
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
Pick-to: 6.0 6.0.0
Change-Id: If4e7ebac23aa63d4b9d4b0a22882dd7d90a58e8b
Reviewed-by: Lars Knoll <[email protected]>
  • Loading branch information
Morten242 committed Nov 21, 2020
1 parent ae2c309 commit f08492c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/corelib/tools/qcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,9 @@ class QCache

bool insert(const Key &key, T *object, qsizetype cost = 1)
{
remove(key);

if (cost > mx) {
delete object;
remove(key);
return false;
}
trim(mx - cost);
Expand Down

0 comments on commit f08492c

Please sign in to comment.