From f08492c6fd9818c7d80b1725355453e179b4d85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 19 Nov 2020 10:52:41 +0100 Subject: [PATCH] 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 Pick-to: 6.0 6.0.0 Change-Id: If4e7ebac23aa63d4b9d4b0a22882dd7d90a58e8b Reviewed-by: Lars Knoll --- src/corelib/tools/qcache.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index 4cfe4a4a48..7c065a8806 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -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);