From 5dd78ba08f31f9aa3c13d4e05ad4478033f7f4e8 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Fri, 12 Aug 2011 20:22:30 +0200 Subject: [PATCH] Replace 'i < len-1 && func(i+1)' by 'i+1 < len && func(i+1)' Merge-request: 1299 Reviewed-by: Oswald Buddenhagen (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 --- examples/painting/gradients/gradients.cpp | 2 +- qmake/generators/makefiledeps.cpp | 2 +- src/corelib/io/qdir.cpp | 6 +++--- src/gui/painting/qpaintengine_raster.cpp | 4 ++-- src/gui/painting/qpaintengine_x11.cpp | 2 +- src/gui/painting/qtessellator.cpp | 2 +- src/gui/widgets/qtabbar.cpp | 2 +- src/sql/kernel/qsqlresult.cpp | 4 ++-- src/tools/moc/moc.cpp | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/painting/gradients/gradients.cpp b/examples/painting/gradients/gradients.cpp index d8b739b..338d8eb 100644 --- a/examples/painting/gradients/gradients.cpp +++ b/examples/painting/gradients/gradients.cpp @@ -219,7 +219,7 @@ void GradientEditor::pointsUpdated() for (int i=0; icolorAt(int(x))) >> 16, (0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8, diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index d6dab0b..f9cbed1 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -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; } diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index d1c9be2..41278f1 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -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) { diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 299f248..45099f9 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -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; } diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 5f613ee..62c1dac 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -2326,7 +2326,7 @@ static QPainterPath path_for_glyphs(const QVarLengthArray &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); } diff --git a/src/gui/painting/qtessellator.cpp b/src/gui/painting/qtessellator.cpp index c469438..94a5128 100644 --- a/src/gui/painting/qtessellator.cpp +++ b/src/gui/painting/qtessellator.cpp @@ -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; } diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 16e4aad..8faf156 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -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; diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index f2b2ccf..71a81c0 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -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; diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 13f57f5..9309db1 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -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 += ' '; } } -- 2.7.4