Replace 'i < len-1 && func(i+1)' by 'i+1 < len && func(i+1)'
authorsuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
Fri, 12 Aug 2011 18:22:30 +0000 (20:22 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 12 Sep 2011 14:03:47 +0000 (16:03 +0200)
Merge-request: 1299
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
(cherry picked from commit 81f0c44f6a4fd4cfa41af5d5b292008185bf3981)

Conflicts:
src/qt3support/itemviews/q3listbox.cpp
src/qt3support/sql/q3datatable.cpp
src/qt3support/text/q3richtext.cpp
src/scripttools/debugging/qscriptcompletiontask.cpp
src/scripttools/debugging/qscriptdebuggercodeview.cpp

Change-Id: Ie70590e77e69fbb9b2322c48c3963fd9cbba19e6
Reviewed-on: http://codereview.qt-project.org/4581
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
examples/painting/gradients/gradients.cpp
qmake/generators/makefiledeps.cpp
src/corelib/io/qdir.cpp
src/gui/painting/qpaintengine_raster.cpp
src/gui/painting/qpaintengine_x11.cpp
src/gui/painting/qtessellator.cpp
src/gui/widgets/qtabbar.cpp
src/sql/kernel/qsqlresult.cpp
src/tools/moc/moc.cpp

index d8b739b..338d8eb 100644 (file)
@@ -219,7 +219,7 @@ void GradientEditor::pointsUpdated()
 
     for (int i=0; i<points.size(); ++i) {
         qreal x = int(points.at(i).x());
-        if (i < points.size() - 1 && x == points.at(i+1).x())
+        if (i+1 < points.size() && x == points.at(i+1).x())
             continue;
         QColor color((0x00ff0000 & m_red_shade->colorAt(int(x))) >> 16,
                      (0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8,
index d6dab0b..f9cbed1 100644 (file)
@@ -499,7 +499,7 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
                             } else if(*(buffer+x) == '*') { //c style comment
                                 for(++x; x < buffer_len; ++x) {
                                     if(*(buffer+x) == '*') {
-                                        if(x < buffer_len-1 && *(buffer + (x+1)) == '/') {
+                                        if(x+1 < buffer_len && *(buffer + (x+1)) == '/') {
                                             ++x;
                                             break;
                                         }
index d1c9be2..41278f1 100644 (file)
@@ -1970,7 +1970,7 @@ QString QDir::cleanPath(const QString &path)
     const QChar *p = name.unicode();
     for (int i = 0, last = -1, iwrite = 0; i < len; ++i) {
         if (p[i] == QLatin1Char('/')) {
-            while (i < len-1 && p[i+1] == QLatin1Char('/')) {
+            while (i+1 < len && p[i+1] == QLatin1Char('/')) {
 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) //allow unc paths
                 if (!i)
                     break;
@@ -1978,9 +1978,9 @@ QString QDir::cleanPath(const QString &path)
                 i++;
             }
             bool eaten = false;
-            if (i < len - 1 && p[i+1] == QLatin1Char('.')) {
+            if (i+1 < len && p[i+1] == QLatin1Char('.')) {
                 int dotcount = 1;
-                if (i < len - 2 && p[i+2] == QLatin1Char('.'))
+                if (i+2 < len && p[i+2] == QLatin1Char('.'))
                     dotcount++;
                 if (i == len - dotcount - 1) {
                     if (dotcount == 1) {
index 299f248..45099f9 100644 (file)
@@ -3488,7 +3488,7 @@ void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSp
                     spans[n].y = y;
                     spans[n].coverage = 255;
                     int len = 1;
-                    while (src_x < w-1 && src[(src_x+1) >> 3] & (0x1 << ((src_x+1) & 7))) {
+                    while (src_x+1 < w && src[(src_x+1) >> 3] & (0x1 << ((src_x+1) & 7))) {
                         ++src_x;
                         ++len;
                     }
@@ -3514,7 +3514,7 @@ void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSp
                     spans[n].y = y;
                     spans[n].coverage = 255;
                     int len = 1;
-                    while (src_x < w-1 && src[(src_x+1) >> 3] & (0x80 >> ((src_x+1) & 7))) {
+                    while (src_x+1 < w && src[(src_x+1) >> 3] & (0x80 >> ((src_x+1) & 7))) {
                         ++src_x;
                         ++len;
                     }
index 5f613ee..62c1dac 100644 (file)
@@ -2326,7 +2326,7 @@ static QPainterPath path_for_glyphs(const QVarLengthArray<glyph_t> &glyphs,
                 bool set = src[x >> 3] & (0x80 >> (x & 7));
                 if (set) {
                     QRect r(xp + x, yp - h, 1, 1);
-                    while (x < glyph->width-1 && src[(x+1) >> 3] & (0x80 >> ((x+1) & 7))) {
+                    while (x+1 < glyph->width && src[(x+1) >> 3] & (0x80 >> ((x+1) & 7))) {
                         ++x;
                         r.setRight(r.right()+1);
                     }
index c469438..94a5128 100644 (file)
@@ -893,7 +893,7 @@ void QTessellatorPrivate::processIntersections()
             QDEBUG() << "    adding edge on left";
             --min;
         }
-        while (max < scanline.size - 1 && scanline.edges[max + 1]->positionAt(y) <=  xmax) {
+        while (max + 1 < scanline.size && scanline.edges[max + 1]->positionAt(y) <=  xmax) {
             QDEBUG() << "    adding edge on right";
             ++max;
         }
index 16e4aad..8faf156 100644 (file)
@@ -171,7 +171,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
 
     if (tabIndex > 0 && tabIndex - 1 == d->currentIndex)
         option->selectedPosition = QStyleOptionTab::PreviousIsSelected;
-    else if (tabIndex < totalTabs - 1 && tabIndex + 1 == d->currentIndex)
+    else if (tabIndex + 1 < totalTabs && tabIndex + 1 == d->currentIndex)
         option->selectedPosition = QStyleOptionTab::NextIsSelected;
     else
         option->selectedPosition = QStyleOptionTab::NotAdjacent;
index f2b2ccf..71a81c0 100644 (file)
@@ -183,7 +183,7 @@ QString QSqlResultPrivate::namedToPositionalBinding()
         QChar ch = sql.at(i);
         if (ch == QLatin1Char(':') && !inQuote
                 && (i == 0 || sql.at(i - 1) != QLatin1Char(':'))
-                && (i < n - 1 && qIsAlnum(sql.at(i + 1)))) {
+                && (i + 1 < n && qIsAlnum(sql.at(i + 1)))) {
             int pos = i + 2;
             while (pos < n && qIsAlnum(sql.at(pos)))
                 ++pos;
@@ -618,7 +618,7 @@ bool QSqlResult::prepare(const QString& query)
         QChar ch = query.at(i);
         if (ch == QLatin1Char(':') && !inQuote
                 && (i == 0 || query.at(i - 1) != QLatin1Char(':'))
-                && (i < n - 1 && qIsAlnum(query.at(i + 1)))) {
+                && (i + 1 < n && qIsAlnum(query.at(i + 1)))) {
             int pos = i + 2;
             while (pos < n && qIsAlnum(query.at(pos)))
                 ++pos;
index 13f57f5..9309db1 100644 (file)
@@ -216,8 +216,8 @@ Type Moc::parseType()
             QByteArray templ = lexemUntil(RANGLE);
             for (int i = 0; i < templ.size(); ++i) {
                 type.name += templ.at(i);
-                if ((templ.at(i) == '<' && i < templ.size()-1 && templ.at(i+1) == ':')
-                    || (templ.at(i) == '>' && i < templ.size()-1 && templ.at(i+1) == '>')) {
+                if ((templ.at(i) == '<' && i+1 < templ.size() && templ.at(i+1) == ':')
+                    || (templ.at(i) == '>' && i+1 < templ.size() && templ.at(i+1) == '>')) {
                     type.name += ' ';
                 }
             }