mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
optimize known values lookup in CSS parser
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
8a7d025857
commit
710bdb4433
1 changed files with 7 additions and 16 deletions
|
@ -343,23 +343,14 @@ static const QCssKnownValue styleFeatures[NumKnownStyleFeatures - 1] = {
|
|||
{ "none", StyleFeature_None }
|
||||
};
|
||||
|
||||
static inline bool operator<(const QString &name, const QCssKnownValue &prop)
|
||||
static inline quint64 findKnownValue(const QString &name, const QCssKnownValue *iter, int numValues)
|
||||
{
|
||||
return QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0;
|
||||
}
|
||||
|
||||
static inline bool operator<(const QCssKnownValue &prop, const QString &name)
|
||||
{
|
||||
return QString::compare(QLatin1String(prop.name), name, Qt::CaseInsensitive) < 0;
|
||||
}
|
||||
|
||||
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)
|
||||
for (int i = 0; i < numValues; i++) {
|
||||
if (name.compare(QLatin1String(iter[i].name), Qt::CaseInsensitive) == 0) {
|
||||
return iter[i].id;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return prop->id;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Reference in a new issue