From cd0a1251232baf17fdfa002d2299305d5613063c Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 14 May 2015 02:47:21 +0400 Subject: Minor optimization to QWidgetPrivate::naturalWidgetFont() When inheritedMask is 0, the font inherits just everything; in this case `inheritedFont.resolve(baseFont)` could be replaced with `baseFont`. Change-Id: Ic3ed8ef174493544ada32037e7bdded46eb4bd43 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/kernel/qwidget.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 49da4d1faf..2d7c03116b 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4699,9 +4699,11 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const if (QWidget *p = q->parentWidget()) { if (!p->testAttribute(Qt::WA_StyleSheet)) { if (!naturalFont.isCopyOf(QApplication::font())) { - QFont inheritedFont = p->font(); - inheritedFont.resolve(inheritedMask); - naturalFont = inheritedFont.resolve(naturalFont); + if (inheritedMask != 0) { + QFont inheritedFont = p->font(); + inheritedFont.resolve(inheritedMask); + naturalFont = inheritedFont.resolve(naturalFont); + } // else nothing to do (naturalFont = naturalFont) } else { naturalFont = p->font(); } @@ -4709,9 +4711,11 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const } #ifndef QT_NO_GRAPHICSVIEW else if (extra && extra->proxyWidget) { - QFont inheritedFont = extra->proxyWidget->font(); - inheritedFont.resolve(inheritedMask); - naturalFont = inheritedFont.resolve(naturalFont); + if (inheritedMask != 0) { + QFont inheritedFont = extra->proxyWidget->font(); + inheritedFont.resolve(inheritedMask); + naturalFont = inheritedFont.resolve(naturalFont); + } // else nothing to do (naturalFont = naturalFont) } #endif //QT_NO_GRAPHICSVIEW } -- cgit v1.2.3