From 0b802b31c894771c9fc5a10184081796b77fa4e6 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Tue, 5 May 2009 18:52:57 +0200
Subject: [PATCH] less inefficient

still quite some potential ...
---
 share/qtcreator/gdbmacros/gdbmacros.cpp | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp
index e5786afc048..fdcbfad0f83 100644
--- a/share/qtcreator/gdbmacros/gdbmacros.cpp
+++ b/share/qtcreator/gdbmacros/gdbmacros.cpp
@@ -221,16 +221,19 @@ Q_DECL_EXPORT char qDumpOutBuffer[100000];
 
 namespace {
 
+static QByteArray strPtrConst = "* const";
+
 static bool isPointerType(const QByteArray &type)
 {
-    return type.endsWith("*") || type.endsWith("* const");
+    return type.endsWith('*') || type.endsWith(strPtrConst);
 }
 
-static QByteArray stripPointerType(QByteArray type)
+static QByteArray stripPointerType(const QByteArray &_type)
 {
-    if (type.endsWith("*"))
+    QByteArray type = _type;
+    if (type.endsWith('*'))
         type.chop(1);
-    if (type.endsWith("* const"))
+    if (type.endsWith(strPtrConst))
         type.chop(7);
     if (type.endsWith(' '))
         type.chop(1);
@@ -279,7 +282,10 @@ static bool isEqual(const char *s, const char *t)
 
 static bool startsWith(const char *s, const char *t)
 {
-    return qstrncmp(s, t, qstrlen(t)) == 0;
+    while (char c = *t++)
+        if (c != *s++)
+            return false;
+    return true;
 }
 
 // Check memory for read access and provoke segfault if nothing else helps.
@@ -293,11 +299,18 @@ static bool startsWith(const char *s, const char *t)
 #    define qCheckPointer(d) do { if (d) qProvokeSegFaultHelper = *(char*)d; } while (0)
 #endif
 
+#ifdef QT_NAMESPACE
 const char *stripNamespace(const char *type)
 {
-    static const size_t nslen = qstrlen(NS);
+    static const size_t nslen = strlen(NS);
     return startsWith(type, NS) ? type + nslen : type;
 }
+#else
+inline const char *stripNamespace(const char *type)
+{
+    return type;
+}
+#endif
 
 static bool isSimpleType(const char *type)
 {
-- 
GitLab