From d9b907e953a475aae9c4eb0a10d7598516ec7b54 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 9 Oct 2018 10:00:23 +0200 Subject: [PATCH] Reduce double and triple lookups to the frames hash Test Plan: Everything runs, tests pass Reviewers: #plasma, davidedmundson, broulik Reviewed By: #plasma, davidedmundson, broulik Subscribers: broulik, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D16060 --- src/plasma/framesvg.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plasma/framesvg.cpp b/src/plasma/framesvg.cpp index 60e69d0e3..fd62a8488 100644 --- a/src/plasma/framesvg.cpp +++ b/src/plasma/framesvg.cpp @@ -958,16 +958,16 @@ QSizeF FrameSvgPrivate::frameSize(FrameData *frame) const void FrameData::ref(FrameSvg *svg) { - references[svg] = references[svg] + 1; + references[svg]++; //qCDebug(LOG_PLASMA) << this << svg << references[svg]; } bool FrameData::deref(FrameSvg *svg) { - references[svg] = references[svg] - 1; - //qCDebug(LOG_PLASMA) << this << svg << references[svg]; - if (references[svg] < 1) { - references.remove(svg); + auto it = references.find(svg); + (*it)--; + if (*it < 1) { + references.erase(it); } return references.isEmpty();