From 5123645831157d6e83fdc85867f778c5073d5082 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 3 Mar 2023 16:23:39 +0100 Subject: [PATCH] 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 Reviewed-by: Qt CI Bot Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qmetaobject.cpp | 6 +++--- 1 file 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; }