QMetaObject: Drop hand-optimization of strcmp
Comparing the first character ahead of a strcmp() call is unlikely to result in faster code than just calling strcmp() right away these days. Any compiler worth its salt should have a specialization of strcmp() that uses platform-specific tricks to produce the best performance. Change-Id: I80b74e698a6636d056b44cbef372edcb417534eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>bb10
parent
b955648224
commit
5123645831
|
|
@ -1047,7 +1047,7 @@ int QMetaObject::indexOfEnumerator(const char *name) const
|
|||
for (int i = 0; i < d->enumeratorCount; ++i) {
|
||||
const QMetaEnum e(m, i);
|
||||
const char *prop = rawStringData(m, e.data.name());
|
||||
if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
|
||||
if (strcmp(name, prop) == 0) {
|
||||
i += m->enumeratorOffset();
|
||||
return i;
|
||||
}
|
||||
|
|
@ -1061,7 +1061,7 @@ int QMetaObject::indexOfEnumerator(const char *name) const
|
|||
for (int i = 0; i < d->enumeratorCount; ++i) {
|
||||
const QMetaEnum e(m, i);
|
||||
const char *prop = rawStringData(m, e.data.alias());
|
||||
if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
|
||||
if (strcmp(name, prop) == 0) {
|
||||
i += m->enumeratorOffset();
|
||||
return i;
|
||||
}
|
||||
|
|
@ -1085,7 +1085,7 @@ int QMetaObject::indexOfProperty(const char *name) const
|
|||
for (int i = 0; i < d->propertyCount; ++i) {
|
||||
const QMetaProperty::Data data = QMetaProperty::getMetaPropertyData(m, i);
|
||||
const char *prop = rawStringData(m, data.name());
|
||||
if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
|
||||
if (strcmp(name, prop) == 0) {
|
||||
i += m->propertyOffset();
|
||||
return i;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue