OSDN Git Service

mark warning cases in QFont as unlikely
authorIvailo Monev <xakepa10@gmail.com>
Sun, 23 Jan 2022 10:38:48 +0000 (12:38 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 23 Jan 2022 10:38:48 +0000 (12:38 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/text/qfont.cpp

index 4164b66..6e46c5e 100644 (file)
@@ -650,7 +650,7 @@ QFont::HintingPreference QFont::hintingPreference() const
 */
 void QFont::setPointSize(int pointSize)
 {
-    if (pointSize <= 0) {
+    if (Q_UNLIKELY(pointSize <= 0)) {
         qWarning("QFont::setPointSize: Point size <= 0 (%d), must be greater than 0", pointSize);
         return;
     }
@@ -672,7 +672,7 @@ void QFont::setPointSize(int pointSize)
 */
 void QFont::setPointSizeF(qreal pointSize)
 {
-    if (pointSize <= 0) {
+    if (Q_UNLIKELY(pointSize <= 0)) {
         qWarning("QFont::setPointSizeF: Point size <= 0 (%f), must be greater than 0", pointSize);
         return;
     }
@@ -707,7 +707,7 @@ qreal QFont::pointSizeF() const
 */
 void QFont::setPixelSize(int pixelSize)
 {
-    if (pixelSize <= 0) {
+    if (Q_UNLIKELY(pixelSize <= 0)) {
         qWarning("QFont::setPixelSize: Pixel size <= 0 (%d)", pixelSize);
         return;
     }
@@ -1007,7 +1007,7 @@ int QFont::stretch() const
 */
 void QFont::setStretch(int factor)
 {
-    if (factor < 1 || factor > 4000) {
+    if (Q_UNLIKELY(factor < 1 || factor > 4000)) {
         qWarning("QFont::setStretch: Parameter '%d' out of range", factor);
         return;
     }
@@ -1244,7 +1244,7 @@ bool QFont::fromString(const QString &descrip)
     QStringList l(descrip.split(QLatin1Char(',')));
 
     int count = l.count();
-    if (!count || count > 8) {
+    if (Q_UNLIKELY(!count || count > 8)) {
         qWarning("QFont::fromString: Invalid description '%s'",
                  descrip.isEmpty() ? "(empty)" : descrip.toLatin1().data());
         return false;