Remove some qBinaryFind usages from QtGui

This is done per the mailing list discussion at
http://www.mail-archive.com/development@qt-project.org/msg01603.html

Change-Id: Iecb921cd778571d24680254566e9aa8fc8d5edff
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
Giuseppe D'Angelo 2013-09-20 16:22:12 +02:00 committed by The Qt Project
parent cc778e1d21
commit bacbf1fcf3
5 changed files with 23 additions and 14 deletions

View File

@ -51,6 +51,8 @@
#include <qimagereader.h>
#include "private/qfunctions_p.h"
#include <algorithm>
#ifndef QT_NO_CSSPARSER
QT_BEGIN_NAMESPACE
@ -358,8 +360,8 @@ Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCssKnownValue &prop, const QStrin
static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)
{
const QCssKnownValue *end = &start[numValues - 1];
const QCssKnownValue *prop = qBinaryFind(start, end, name);
if (prop == end)
const QCssKnownValue *prop = std::lower_bound(start, end, name);
if ((prop == end) || (name < *prop))
return 0;
return prop->id;
}

View File

@ -101,8 +101,8 @@ QByteArray QFontSubset::glyphName(unsigned short unicode, bool symbol)
// map from latin1 to symbol
unicode = symbol_map[unicode];
const AGLEntry *r = qBinaryFind(unicode_to_agl_map, unicode_to_agl_map + unicode_to_agl_map_size, unicode);
if (r != unicode_to_agl_map + unicode_to_agl_map_size)
const AGLEntry *r = std::lower_bound(unicode_to_agl_map, unicode_to_agl_map + unicode_to_agl_map_size, unicode);
if ((r != unicode_to_agl_map + unicode_to_agl_map_size) && !(unicode < *r))
return glyph_names + r->index;
char buffer[8];

View File

@ -2969,7 +2969,10 @@ void QTextEngine::resolveAdditionalFormats() const
}
while (endIt != addFormatSortedByEnd.constEnd() &&
specialData->addFormats.at(*endIt).start + specialData->addFormats.at(*endIt).length < end) {
currentFormats.remove(qBinaryFind(currentFormats, *endIt) - currentFormats.begin());
int *currentFormatIterator = std::lower_bound(currentFormats.begin(), currentFormats.end(), *endIt);
if (*endIt < *currentFormatIterator)
currentFormatIterator = currentFormats.end();
currentFormats.remove(currentFormatIterator - currentFormats.begin());
++endIt;
}
QTextCharFormat format;

View File

@ -55,6 +55,8 @@
#include "qfont_p.h"
#include "private/qfunctions_p.h"
#include <algorithm>
#ifndef QT_NO_TEXTHTMLPARSER
QT_BEGIN_NAMESPACE
@ -336,8 +338,8 @@ static QChar resolveEntity(const QString &entity)
{
const QTextHtmlEntity *start = &entities[0];
const QTextHtmlEntity *end = &entities[MAX_ENTITY];
const QTextHtmlEntity *e = qBinaryFind(start, end, entity);
if (e == end)
const QTextHtmlEntity *e = std::lower_bound(start, end, entity);
if (e == end || (entity < *e))
return QChar();
return e->code;
}
@ -456,8 +458,8 @@ static const QTextHtmlElement *lookupElementHelper(const QString &element)
{
const QTextHtmlElement *start = &elements[0];
const QTextHtmlElement *end = &elements[Html_NumElements];
const QTextHtmlElement *e = qBinaryFind(start, end, element);
if (e == end)
const QTextHtmlElement *e = std::lower_bound(start, end, element);
if ((e == end) || (element < *e))
return 0;
return e;
}

View File

@ -393,10 +393,10 @@ int QTextTablePrivate::findCellIndex(int fragment) const
{
QFragmentFindHelper helper(pieceTable->fragmentMap().position(fragment),
pieceTable->fragmentMap());
QList<int>::ConstIterator it = qBinaryFind(cells.begin(), cells.end(), helper);
if (it == cells.end())
QList<int>::ConstIterator it = std::lower_bound(cells.constBegin(), cells.constEnd(), helper);
if ((it == cells.constEnd()) || (helper < *it))
return -1;
return it - cells.begin();
return it - cells.constBegin();
}
void QTextTablePrivate::fragmentAdded(QChar type, uint fragment)
@ -1048,8 +1048,9 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols)
// find the position at which to insert the contents of the merged cells
QFragmentFindHelper helper(origCellPosition, p->fragmentMap());
QList<int>::Iterator it = qBinaryFind(d->cells.begin(), d->cells.end(), helper);
QList<int>::Iterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper);
Q_ASSERT(it != d->cells.end());
Q_ASSERT(!(helper < *it));
Q_ASSERT(*it == cellFragment);
const int insertCellIndex = it - d->cells.begin();
int insertFragment = d->cells.value(insertCellIndex + 1, d->fragment_end);
@ -1080,8 +1081,9 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols)
if (firstCellIndex == -1) {
QFragmentFindHelper helper(pos, p->fragmentMap());
QList<int>::Iterator it = qBinaryFind(d->cells.begin(), d->cells.end(), helper);
QList<int>::Iterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper);
Q_ASSERT(it != d->cells.end());
Q_ASSERT(!(helper < *it));
Q_ASSERT(*it == fragment);
firstCellIndex = cellIndex = it - d->cells.begin();
}