summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2013-09-20 16:22:12 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-23 21:20:47 +0200
commitbacbf1fcf35afcece74270fda5521d43b039ee48 (patch)
treeced3c76a8275c976a54847e9df542077996c68f5 /src/gui
parentcc778e1d2108806ef5d14b87eddd3ce8999c27ee (diff)
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>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qcssparser.cpp6
-rw-r--r--src/gui/text/qfontsubset.cpp4
-rw-r--r--src/gui/text/qtextengine.cpp5
-rw-r--r--src/gui/text/qtexthtmlparser.cpp10
-rw-r--r--src/gui/text/qtexttable.cpp12
5 files changed, 23 insertions, 14 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index b486ec05fa..7a96fbe88b 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -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;
}
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index 01ae5888e2..152e15a54d 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -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];
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 241ed21a10..e571e8da8a 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -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;
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index e99ba49107..c177fa0810 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -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;
}
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index a56f8060e0..879c3ddc70 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -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();
}