From 81f0c44f6a4fd4cfa41af5d5b292008185bf3981 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Fri, 12 Aug 2011 20:22:30 +0200 Subject: Replace 'i < len-1 && func(i+1)' by 'i+1 < len && func(i+1)' Merge-request: 1299 Reviewed-by: Oswald Buddenhagen --- demos/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/qt3support/itemviews/q3listbox.cpp | 6 +++--- src/qt3support/sql/q3datatable.cpp | 2 +- src/qt3support/text/q3richtext.cpp | 2 +- src/scripttools/debugging/qscriptcompletiontask.cpp | 2 +- src/scripttools/debugging/qscriptdebuggercodeview.cpp | 2 +- src/sql/kernel/qsqlresult.cpp | 4 ++-- src/tools/moc/moc.cpp | 4 ++-- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/demos/gradients/gradients.cpp b/demos/gradients/gradients.cpp index d8b739b..338d8eb 100644 --- a/demos/gradients/gradients.cpp +++ b/demos/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 f9196e0..3db3dfc 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2004,7 +2004,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; @@ -2012,9 +2012,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 76d7316..b4b55de 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3552,7 +3552,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; } @@ -3578,7 +3578,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 147d2ec..17d141c 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -2333,7 +2333,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/qt3support/itemviews/q3listbox.cpp b/src/qt3support/itemviews/q3listbox.cpp index 796a3b8..f1574df 100644 --- a/src/qt3support/itemviews/q3listbox.cpp +++ b/src/qt3support/itemviews/q3listbox.cpp @@ -3531,9 +3531,9 @@ void Q3ListBox::refreshSlot() int col = columnAt(x); int row = rowAt(y); int top = row; - while(col < (int)d->columnPos.size()-1 && d->columnPos[col+1] < x) + while(col+1 < (int)d->columnPos.size() && d->columnPos[col+1] < x) col++; - while(top < (int)d->rowPos.size()-1 && d->rowPos[top+1] < y) + while(top+1 < (int)d->rowPos.size() && d->rowPos[top+1] < y) top++; Q3ListBoxItem * i = item(col * numRows() + row); @@ -3684,7 +3684,7 @@ int Q3ListBox::columnAt(int x) const return numColumns() - 1; int col = 0; - while(col < (int)d->columnPos.size()-1 && d->columnPos[col+1] < x) + while(col+1 < (int)d->columnPos.size() && d->columnPos[col+1] < x) col++; return col; } diff --git a/src/qt3support/sql/q3datatable.cpp b/src/qt3support/sql/q3datatable.cpp index 39ef1d9..35e9fda 100644 --- a/src/qt3support/sql/q3datatable.cpp +++ b/src/qt3support/sql/q3datatable.cpp @@ -710,7 +710,7 @@ bool Q3DataTable::eventFilter( QObject *o, QEvent *e ) return true; } if ( d->dat.mode() != QSql::None ) { - if ( (ke->key() == Qt::Key_Tab) && (c < numCols() - 1) && (!isColumnReadOnly( c+1 ) || d->dat.mode() == QSql::Insert) ) + if ( (ke->key() == Qt::Key_Tab) && (c+1 < numCols()) && (!isColumnReadOnly( c+1 ) || d->dat.mode() == QSql::Insert) ) d->continuousEdit = true; else if ( (ke->key() == Qt::Key_BackTab) && (c > 0) && (!isColumnReadOnly( c-1 ) || d->dat.mode() == QSql::Insert) ) d->continuousEdit = true; diff --git a/src/qt3support/text/q3richtext.cpp b/src/qt3support/text/q3richtext.cpp index dc1476c..c367c0c 100644 --- a/src/qt3support/text/q3richtext.cpp +++ b/src/qt3support/text/q3richtext.cpp @@ -121,7 +121,7 @@ static inline bool isBreakable(Q3TextString *string, int pos) { if (string->at(pos).nobreak) return false; - return (pos < string->length()-1 && string->at(pos+1).softBreak); + return (pos+1 < string->length() && string->at(pos+1).softBreak); } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/src/scripttools/debugging/qscriptcompletiontask.cpp b/src/scripttools/debugging/qscriptcompletiontask.cpp index fb250b7..3c94a21 100644 --- a/src/scripttools/debugging/qscriptcompletiontask.cpp +++ b/src/scripttools/debugging/qscriptcompletiontask.cpp @@ -172,7 +172,7 @@ void QScriptCompletionTaskPrivate::completeScriptExpression() while ((pos > 0) && isIdentChar(contents.at(pos-1))) --pos; int pos2 = cursorPosition - 1; - while ((pos2 < contents.size()-1) && isIdentChar(contents.at(pos2+1))) + while ((pos2+1 < contents.size()) && isIdentChar(contents.at(pos2+1))) ++pos2; QString ident = contents.mid(pos, pos2 - pos + 1); position = pos; diff --git a/src/scripttools/debugging/qscriptdebuggercodeview.cpp b/src/scripttools/debugging/qscriptdebuggercodeview.cpp index 7c99723..65fd366 100644 --- a/src/scripttools/debugging/qscriptdebuggercodeview.cpp +++ b/src/scripttools/debugging/qscriptdebuggercodeview.cpp @@ -233,7 +233,7 @@ bool QScriptDebuggerCodeView::event(QEvent *e) return false; } int pos2 = linePosition - 1; - while ((pos2 < contents.size()-1) && isIdentChar(contents.at(pos2+1))) + while ((pos2+1 < contents.size()) && isIdentChar(contents.at(pos2+1))) ++pos2; QString ident = contents.mid(pos, pos2 - pos + 1); 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 += ' '; } } -- cgit v0.12