summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-08-26 14:32:37 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:19 -0300
commit16dc50e25109274f400a064b4d672384d09b22f7 (patch)
tree8cf3f321257fb48380ac2b1b723bea872e537395
parentdfd0bc442d5f3c04d03ee23606b399ed18d304f7 (diff)
Optimize isCppPrimitive function.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--typesystem.cpp34
1 files changed, 7 insertions, 27 deletions
diff --git a/typesystem.cpp b/typesystem.cpp
index b99cf2fc..9976d47f 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -2148,37 +2148,17 @@ bool TypeEntry::isCppPrimitive() const
{
if (!isPrimitive())
return false;
- if (m_name.contains(' ') || m_type == VoidType)
+
+ PrimitiveTypeEntry* aliasedType = ((PrimitiveTypeEntry*)this)->basicAliasedTypeEntry();
+ QByteArray typeName = (aliasedType ? aliasedType->name() : m_name).toAscii();
+
+ if (typeName.contains(' ') || m_type == VoidType)
return true;
// Keep this sorted!!
- static const char* cppTypes[] = { "bool", "char", "double", "float", "int", "long", "long long", "short",
- "unsigned char", "unsigned double", "unsigned float", "unsigned int",
- "unsigned long", "unsigned long long", "unsigned short", "wchar_t" };
+ static const char* cppTypes[] = { "bool", "char", "double", "float", "int", "long", "long long", "short", "wchar_t" };
const int N = sizeof(cppTypes)/sizeof(char*);
- PrimitiveTypeEntry* aliasedType = ((PrimitiveTypeEntry*)this)->basicAliasedTypeEntry();
- QString typeName = aliasedType ? aliasedType->name() : m_name;
+ const char** res = qBinaryFind(&cppTypes[0], &cppTypes[N], typeName.constData(), strLess);
- const char** res = qBinaryFind(&cppTypes[0], &cppTypes[N], typeName.toAscii().constData(), strLess);
return res != &cppTypes[N];
}
-
-/*
-static void injectCode(ComplexTypeEntry *e,
- const char *signature,
- const QByteArray &code,
- const ArgumentMap &args)
-{
- CodeSnip snip;
- snip.language = TypeSystem::NativeCode;
- snip.position = CodeSnip::Beginning;
- snip.addCode(QString::fromLatin1(code));
- snip.argumentMap = args;
-
- FunctionModification mod;
- mod.signature = QMetaObject::normalizedSignature(signature);
- mod.snips << snip;
- mod.modifiers = Modification::CodeInjection;
-}
-*/
-