OSDN Git Service

avoid temporary in QStyle::itemTextRect()
authorIvailo Monev <xakepa10@laimg.moc>
Thu, 4 Jul 2019 14:15:21 +0000 (14:15 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Thu, 4 Jul 2019 14:15:21 +0000 (14:15 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/styles/qstyle.cpp

index 06570bc..d6253a2 100644 (file)
@@ -456,19 +456,17 @@ void QStyle::polish(QPalette & /* pal */)
 QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
                        const QString &text) const
 {
-    QRect result;
     int x, y, w, h;
     rect.getRect(&x, &y, &w, &h);
     if (!text.isEmpty()) {
-        result = metrics.boundingRect(x, y, w, h, alignment, text);
+        QRect result = metrics.boundingRect(x, y, w, h, alignment, text);
         if (!enabled && proxy()->styleHint(SH_EtchDisabledText)) {
             result.setWidth(result.width()+1);
             result.setHeight(result.height()+1);
         }
-    } else {
-        result = QRect(x, y, w, h);
+        return result;
     }
-    return result;
+    return QRect(x, y, w, h);
 }
 
 /*!