From 2b671a5452d9f8c528948e4dcd707a11d3b8962b Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 17 Feb 2011 15:47:23 -0200 Subject: Add more cache stuff to speed up the generation process. --- abstractmetalang.cpp | 79 ++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 39 deletions(-) (limited to 'abstractmetalang.cpp') diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp index 3dc48fac7..b1f5fd6e9 100644 --- a/abstractmetalang.cpp +++ b/abstractmetalang.cpp @@ -84,32 +84,32 @@ AbstractMetaType *AbstractMetaType::copy() const QString AbstractMetaType::cppSignature() const { - QString s; - - if (isConstant()) - s += "const "; - - s += typeEntry()->qualifiedCppName(); - - if (hasInstantiationInCpp()) { - AbstractMetaTypeList types = instantiations(); - s += "<"; - for (int i = 0; i < types.count(); ++i) { - if (i > 0) - s += ", "; - s += types[i]->cppSignature(); + if (m_cachedCppSignature.isEmpty()) { + if (isConstant()) + m_cachedCppSignature += "const "; + + m_cachedCppSignature += typeEntry()->qualifiedCppName(); + + if (hasInstantiationInCpp()) { + AbstractMetaTypeList types = instantiations(); + m_cachedCppSignature += "<"; + for (int i = 0; i < types.count(); ++i) { + if (i > 0) + m_cachedCppSignature += ", "; + m_cachedCppSignature += types[i]->cppSignature(); + } + m_cachedCppSignature += " >"; } - s += " >"; - } - if (actualIndirections()) { - s += ' '; - if (indirections()) - s += QString(indirections(), '*'); - if (isReference()) - s += '&'; + if (actualIndirections()) { + m_cachedCppSignature += ' '; + if (indirections()) + m_cachedCppSignature += QString(indirections(), '*'); + if (isReference()) + m_cachedCppSignature += '&'; + } } - return s; + return m_cachedCppSignature; } @@ -326,26 +326,27 @@ QStringList AbstractMetaFunction::introspectionCompatibleSignatures(const QStrin QString AbstractMetaFunction::signature() const { - QString s(m_originalName); + if (m_cachedSignature.isEmpty()) { + m_cachedSignature = m_originalName; - s += "("; - - for (int i = 0; i < m_arguments.count(); ++i) { - if (i > 0) - s += ", "; - AbstractMetaArgument *a = m_arguments.at(i); - s += a->type()->cppSignature(); + m_cachedSignature += '('; - // We need to have the argument names in the qdoc files - s += " "; - s += a->name(); - } - s += ")"; + for (int i = 0; i < m_arguments.count(); ++i) { + if (i > 0) + m_cachedSignature += ", "; + AbstractMetaArgument *a = m_arguments.at(i); + m_cachedSignature += a->type()->cppSignature(); - if (isConstant()) - s += " const"; + // We need to have the argument names in the qdoc files + m_cachedSignature += ' '; + m_cachedSignature += a->name(); + } + m_cachedSignature += ")"; - return s; + if (isConstant()) + m_cachedSignature += " const"; + } + return m_cachedSignature; } int AbstractMetaFunction::actualMinimumArgumentCount() const -- cgit v1.2.3