summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetaobject.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-03-03 16:23:39 +0100
committerUlf Hermann <ulf.hermann@qt.io>2023-03-06 08:41:19 +0100
commit5123645831157d6e83fdc85867f778c5073d5082 (patch)
treeb32640adb75fac2299a2850ee8922e8054578c40 /src/corelib/kernel/qmetaobject.cpp
parentb955648224929e07b133744742344b9a45ae9c9e (diff)
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>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
-rw-r--r--src/corelib/kernel/qmetaobject.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index c82f25fa94..09692600c3 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -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;
}