From 46d4dc8afb4c38165b3b050e44170d9f3b03a0f5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2017 00:48:33 +0100 Subject: QStyleSheetStyle: optimize away triple key lookup Instead of contains()/value()/remove(), all of which perform a new lookup, and a new application of qHash(), get an iterator using find(), deref it, then pass it to erase(). Also add some optimistic std::move(). Change-Id: I27a623dcd974de9c67d11d030e9b98d7598efc93 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qstylesheetstyle.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 9be19b2679..65894a6dde 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2607,9 +2607,10 @@ void QStyleSheetStyle::unsetPalette(QWidget *w) const bool useStyleSheetPropagationInWidgetStyles = QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); - if (styleSheetCaches->customPaletteWidgets.contains(w)) { - QPair p = styleSheetCaches->customPaletteWidgets.value(w); - styleSheetCaches->customPaletteWidgets.remove(w); + const auto it = styleSheetCaches->customPaletteWidgets.find(w); + if (it != styleSheetCaches->customPaletteWidgets.end()) { + QPair p = std::move(*it); + styleSheetCaches->customPaletteWidgets.erase(it); QPalette original = p.first; @@ -2649,9 +2650,10 @@ void QStyleSheetStyle::unsetPalette(QWidget *w) void QStyleSheetStyle::unsetStyleSheetFont(QWidget *w) const { - if (styleSheetCaches->customFontWidgets.contains(w)) { - QPair f = styleSheetCaches->customFontWidgets.value(w); - styleSheetCaches->customFontWidgets.remove(w); + const auto it = styleSheetCaches->customFontWidgets.find(w); + if (it != styleSheetCaches->customFontWidgets.end()) { + QPair f = std::move(*it); + styleSheetCaches->customFontWidgets.erase(it); QFont original = f.first; original.resolve(original.resolve() & f.second); -- cgit v1.2.3