Remove qBinaryFind usages from bootstrapped files

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

Change-Id: I492b49553bc889892f5ca0c47aa13c75e11518e2
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Giuseppe D'Angelo 2013-09-20 16:22:12 +02:00 committed by The Qt Project
parent 6a12da7fb3
commit 73637b7d1a
2 changed files with 11 additions and 7 deletions

View File

@ -54,6 +54,8 @@
#include "qunicodetables_p.h"
#include "qunicodetables.cpp"
#include <algorithm>
QT_BEGIN_NAMESPACE
#define FLAG(x) (1 << (x))
@ -1719,13 +1721,13 @@ static uint inline ligatureHelper(uint u1, uint u2)
ushort length = *ligatures++;
if (QChar::requiresSurrogates(u1)) {
const UCS2SurrogatePair *data = reinterpret_cast<const UCS2SurrogatePair *>(ligatures);
const UCS2SurrogatePair *r = qBinaryFind(data, data + length, u1);
if (r != data + length)
const UCS2SurrogatePair *r = std::lower_bound(data, data + length, u1);
if (r != data + length && QChar::surrogateToUcs4(r->p1.u1, r->p1.u2) == u1)
return QChar::surrogateToUcs4(r->p2.u1, r->p2.u2);
} else {
const UCS2Pair *data = reinterpret_cast<const UCS2Pair *>(ligatures);
const UCS2Pair *r = qBinaryFind(data, data + length, ushort(u1));
if (r != data + length)
const UCS2Pair *r = std::lower_bound(data, data + length, ushort(u1));
if (r != data + length && r->u1 == ushort(u1))
return r->u2;
}

View File

@ -56,6 +56,7 @@
#include "private/qfunctions_p.h"
#include <limits.h>
#include <algorithm>
QT_BEGIN_NAMESPACE
@ -1537,7 +1538,7 @@ void QRegExpEngine::addPlusTransitions(const QVector<int> &from, const QVector<i
for (int j = 0; j < to.size(); j++) {
// ### st.reenter.contains(to.at(j)) check looks suspicious
if (!st.reenter.contains(to.at(j)) &&
qBinaryFind(oldOuts.constBegin(), oldOuts.constEnd(), to.at(j)) == oldOuts.end())
!std::binary_search(oldOuts.constBegin(), oldOuts.constEnd(), to.at(j)))
st.reenter.insert(to.at(j), atom);
}
}
@ -3245,8 +3246,9 @@ int QRegExpEngine::getEscape()
}
} else if (catlen > 2 && category.at(0) == 'I' && category.at(1) == 's') {
static const int N = sizeof(categoriesRangeMap) / sizeof(categoriesRangeMap[0]);
const CategoriesRangeMapEntry *r = qBinaryFind(categoriesRangeMap, categoriesRangeMap + N, category.constData() + 2);
if (r != categoriesRangeMap + N)
const char * const categoryFamily = category.constData() + 2;
const CategoriesRangeMapEntry *r = std::lower_bound(categoriesRangeMap, categoriesRangeMap + N, categoryFamily);
if (r != categoriesRangeMap + N && qstrcmp(r->name, categoryFamily) == 0)
yyCharClass->addRange(r->first, r->second);
else
error(RXERR_CATEGORY);