[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sdk/kdevplatform/language/duchain
From:       Milian Wolff <mail () milianw ! de>
Date:       2010-04-07 15:25:40
Message-ID: 20100407152540.76D32AC897 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1112201 by mwolff:

const ref in uses of custom FOREACH_ macros, should improve performance but my test \
doesn't show such a big gain as I hoped for

 M  +2 -2      declaration.cpp  
 M  +1 -1      definitions.cpp  
 M  +1 -1      duchainutils.cpp  
 M  +19 -19    ducontext.cpp  
 M  +1 -1      functiondefinition.cpp  
 M  +6 -6      identifier.cpp  
 M  +1 -1      importers.cpp  
 M  +5 -5      topducontext.cpp  
 M  +2 -2      topducontextdynamicdata.cpp  
 M  +2 -2      types/functiontype.cpp  
 M  +3 -3      types/unsuretype.cpp  
 M  +1 -1      uses.cpp  


--- trunk/extragear/sdk/kdevplatform/language/duchain/declaration.cpp \
#1112200:1112201 @@ -732,7 +732,7 @@
 
   KDevVarLengthArray<IndexedTopDUContext> useContexts = DUChain::uses()->uses(id());
 
-  FOREACH_ARRAY(IndexedTopDUContext indexedContext, useContexts) {
+  FOREACH_ARRAY(const IndexedTopDUContext& indexedContext, useContexts) {
     if(!indexedContext.isLoaded())
       continue;
     TopDUContext* context = indexedContext.data();
@@ -759,7 +759,7 @@
 
   KDevVarLengthArray<IndexedTopDUContext> useContexts = DUChain::uses()->uses(id());
 
-  FOREACH_ARRAY(IndexedTopDUContext indexedContext, useContexts) {
+  FOREACH_ARRAY(const IndexedTopDUContext& indexedContext, useContexts) {
     TopDUContext* context = indexedContext.data();
     if(context) {
       QMap<SimpleRange, bool>& ranges(tempUses[context->url()]);
--- trunk/extragear/sdk/kdevplatform/language/duchain/definitions.cpp \
#1112200:1112201 @@ -180,7 +180,7 @@
   
   if(index) {
     const DefinitionsItem* repositoryItem = d->m_definitions.itemFromIndex(index);
-    FOREACH_FUNCTION(IndexedDeclaration decl, repositoryItem->definitions)
+    FOREACH_FUNCTION(const IndexedDeclaration& decl, repositoryItem->definitions)
       ret.append(decl);
   }
   
--- trunk/extragear/sdk/kdevplatform/language/duchain/duchainutils.cpp \
#1112200:1112201 @@ -428,7 +428,7 @@
     return ret;
 
   if(decl->internalContext() && decl->internalContext()->type() == DUContext::Class)
-    FOREACH_ARRAY(IndexedDUContext importer, \
decl->internalContext()->indexedImporters()) { +    FOREACH_ARRAY(const \
IndexedDUContext& importer, decl->internalContext()->indexedImporters()) {  
       DUContext* imp = importer.data();
       
--- trunk/extragear/sdk/kdevplatform/language/duchain/ducontext.cpp #1112200:1112201
@@ -287,7 +287,7 @@
 {
   m_hasLocalDeclarationsHash = true;
 
-  FOREACH_FUNCTION(LocalIndexedDeclaration indexedDecl, \
ctx->d_func()->m_localDeclarations) { +  FOREACH_FUNCTION(const \
LocalIndexedDeclaration& indexedDecl, ctx->d_func()->m_localDeclarations) {  \
Declaration* decl = indexedDecl.data(m_topContext);  Q_ASSERT(decl);
     if(currentDecl != decl)
@@ -296,7 +296,7 @@
       m_localDeclarationsHash.insert( currentIdentifier, DeclarationPointer(decl) );
   }
 
-  FOREACH_FUNCTION(LocalIndexedDUContext child, ctx->d_func()->m_childContexts) {
+  FOREACH_FUNCTION(const LocalIndexedDUContext& child, \
ctx->d_func()->m_childContexts) {  DUContext* childCtx = child.data(m_topContext);
     Q_ASSERT(childCtx);
     if(childCtx->d_func()->m_propagateDeclarations)
@@ -323,7 +323,7 @@
 
   uint propagatingChildContexts = 0;
 
-  FOREACH_FUNCTION(LocalIndexedDUContext child, \
m_context->d_func()->m_childContexts) { +  FOREACH_FUNCTION(const \
LocalIndexedDUContext& child, m_context->d_func()->m_childContexts) {  DUContext* \
childCtx = child.data(m_topContext);  Q_ASSERT(childCtx);
     if(childCtx->d_func()->m_propagateDeclarations)
@@ -637,7 +637,7 @@
   ENSURE_CAN_READ
 
   QVector< DUContext * > ret;
-  FOREACH_FUNCTION(LocalIndexedDUContext ctx, d_func()->m_childContexts)
+  FOREACH_FUNCTION(const LocalIndexedDUContext& ctx, d_func()->m_childContexts)
     ret << ctx.data(topContext());
   return ret;
 }
@@ -907,7 +907,7 @@
   }
   
   QList<QualifiedIdentifier> ret;
-  FOREACH_ARRAY(SearchItem::Ptr item, identifiers)
+  FOREACH_ARRAY(const SearchItem::Ptr& item, identifiers)
     ret += item->toList();
   
   return ret;
@@ -999,7 +999,7 @@
   if(owner())
     ret = Importers::self().importers(owner()->id()); //Add indirect importers to \
the list  
-  FOREACH_FUNCTION(IndexedDUContext ctx, d_func()->m_importers)
+  FOREACH_FUNCTION(const IndexedDUContext& ctx, d_func()->m_importers)
     ret.append(ctx);
    
   return ret;
@@ -1010,13 +1010,13 @@
   ENSURE_CAN_READ
 
   QVector<DUContext*> ret;
-  FOREACH_FUNCTION(IndexedDUContext ctx, d_func()->m_importers)
+  FOREACH_FUNCTION(const IndexedDUContext& ctx, d_func()->m_importers)
     ret << ctx.context();
   
   if(owner()) {
     //Add indirect importers to the list
     KDevVarLengthArray<IndexedDUContext> indirect = \
                Importers::self().importers(owner()->id());
-    FOREACH_ARRAY(IndexedDUContext ctx, indirect) {
+    FOREACH_ARRAY(const IndexedDUContext& ctx, indirect) {
       ret << ctx.context();
     }
   }
@@ -1031,7 +1031,7 @@
   if (!parent)
     parent = const_cast<DUContext*>(this);
 
-  FOREACH_FUNCTION(LocalIndexedDUContext context, parent->d_func()->m_childContexts)
+  FOREACH_FUNCTION(const LocalIndexedDUContext& context, \
parent->d_func()->m_childContexts)  if \
(context.data(topContext())->range().contains(position)) {  DUContext* ret = \
findContext(position, context.data(topContext()));  if (!ret)
@@ -1048,7 +1048,7 @@
   if (this == context)
     return true;
 
-  FOREACH_FUNCTION(LocalIndexedDUContext child, d_func()->m_childContexts) {
+  FOREACH_FUNCTION(const LocalIndexedDUContext& child, d_func()->m_childContexts) {
     if (child.data(topContext())->parentContextOf(context))
       return true;
   }
@@ -1076,7 +1076,7 @@
 
   QMutexLocker lock(&DUContextDynamicData::m_localDeclarationsMutex);
   QVector<Declaration*> ret;
-  FOREACH_FUNCTION(LocalIndexedDeclaration decl, d_func()->m_localDeclarations) {
+  FOREACH_FUNCTION(const LocalIndexedDeclaration& decl, \
d_func()->m_localDeclarations) {  ret << decl.data(topContext());
   }
 
@@ -1154,7 +1154,7 @@
   TopDUContext* top = topContext();
   //If we are deleting something that is not stored to disk, we need to create + \
delete the declarations,  //so their destructor unregisters from the persistent \
                symbol table and from TopDUContextDynamicData
-  FOREACH_ARRAY(LocalIndexedDeclaration decl, declarations)
+  FOREACH_ARRAY(const LocalIndexedDeclaration& decl, declarations)
     if(decl.isLoaded(top) || !top->deleting() || !top->isOnDisk())
       delete decl.data(top);
 }
@@ -1166,7 +1166,7 @@
   TopDUContext* top = topContext();
 
   QVector<LocalIndexedDUContext> children;
-  FOREACH_FUNCTION(LocalIndexedDUContext ctx, d_func()->m_childContexts)
+  FOREACH_FUNCTION(const LocalIndexedDUContext& ctx, d_func()->m_childContexts)
     children << ctx;
 
   //If we are deleting a context that is already stored to disk, we don't need to \
load not yet loaded child-contexts. @@ -1317,7 +1317,7 @@
 {
   deleteUses();
   
-  FOREACH_FUNCTION(LocalIndexedDUContext childContext, d_func()->m_childContexts)
+  FOREACH_FUNCTION(const LocalIndexedDUContext& childContext, \
d_func()->m_childContexts)  childContext.data(topContext())->deleteUsesRecursively();
 }
 
@@ -1589,7 +1589,7 @@
   if (!range().contains(position))
     return 0;
 
-  FOREACH_FUNCTION(LocalIndexedDeclaration child, d_func()->m_localDeclarations)
+  FOREACH_FUNCTION(const LocalIndexedDeclaration& child, \
d_func()->m_localDeclarations)  if \
(child.data(topContext())->range().contains(position))  return \
child.data(topContext());  
@@ -1603,7 +1603,7 @@
   if (!this->range().contains(range))
     return 0;
 
-  FOREACH_FUNCTION(LocalIndexedDUContext child, d_func()->m_childContexts)
+  FOREACH_FUNCTION(const LocalIndexedDUContext& child, d_func()->m_childContexts)
     if (DUContext* specific = child.data(topContext())->findContextIncluding(range))
       return specific;
 
@@ -1663,7 +1663,7 @@
   //Copy since the array may change during the iteration
   KDevVarLengthArray<LocalIndexedDUContext, 10> childrenCopy = \
d_func_dynamic()->m_childContextsList();  
-  FOREACH_ARRAY(LocalIndexedDUContext childContext, childrenCopy)
+  FOREACH_ARRAY(const LocalIndexedDUContext& childContext, childrenCopy)
     if (!encountered.contains(childContext.data(topContext())))
       delete childContext.data(topContext());
 }
@@ -1683,7 +1683,7 @@
   if(!m_dynamicData->m_rangesForUses.isEmpty())
     m_dynamicData->m_rangesForUses.squeeze();
 
-  FOREACH_FUNCTION(LocalIndexedDUContext child, d_func()->m_childContexts)
+  FOREACH_FUNCTION(const LocalIndexedDUContext& child, d_func()->m_childContexts)
     child.data(topContext())->squeeze();
 }
 
@@ -1821,7 +1821,7 @@
 
 void DUContext::SearchItem::addToEachNode(SearchItem::PtrList other) {
   int added = 0;
-  FOREACH_ARRAY(SearchItem::Ptr o, other) {
+  FOREACH_ARRAY(const SearchItem::Ptr& o, other) {
     if(!o->isExplicitlyGlobal) {
       next.append(o);
       ++added;
--- trunk/extragear/sdk/kdevplatform/language/duchain/functiondefinition.cpp \
#1112200:1112201 @@ -81,7 +81,7 @@
 {
   ENSURE_CHAIN_READ_LOCKED
   KDevVarLengthArray<IndexedDeclaration> allDefinitions = \
                DUChain::definitions()->definitions(decl->id());
-  FOREACH_ARRAY(IndexedDeclaration decl, allDefinitions) {
+  FOREACH_ARRAY(const IndexedDeclaration& decl, allDefinitions) {
     if(decl.data()) ///@todo Find better ways of deciding which definition to use
       return dynamic_cast<FunctionDefinition*>(decl.data());
   }
--- trunk/extragear/sdk/kdevplatform/language/duchain/identifier.cpp #1112200:1112201
@@ -76,7 +76,7 @@
       //this must stay thread-safe(may be called by multiple threads at a time)
       //The thread-safety is given because all threads will have the same result, \
and it will only be written once at the end.  uint hash = m_identifier.hash();
-      FOREACH_FUNCTION(IndexedTypeIdentifier templateIdentifier, \
templateIdentifiers) +      FOREACH_FUNCTION(const IndexedTypeIdentifier& \
                templateIdentifier, templateIdentifiers)
         hash = hash * 13 + IndexedTypeIdentifier(templateIdentifier).hash();
       hash += m_unique;
       m_hash = hash;
@@ -209,7 +209,7 @@
     if( m_hash == 0 )
     {
       uint mhash = 0;
-      FOREACH_FUNCTION( IndexedIdentifier identifier, identifiers )
+      FOREACH_FUNCTION( const IndexedIdentifier& identifier, identifiers )
         mhash = 11*mhash + Identifier(identifier).hash();
 
       if(mhash != m_hash)
@@ -592,10 +592,10 @@
     ret.append(QString());
 
   if(m_index) {
-    FOREACH_FUNCTION(IndexedIdentifier index, cd->identifiers)
+    FOREACH_FUNCTION(const IndexedIdentifier& index, cd->identifiers)
       ret << index.identifier().toString();
   }else{
-    FOREACH_FUNCTION(IndexedIdentifier index, dd->identifiers)
+    FOREACH_FUNCTION(const IndexedIdentifier& index, dd->identifiers)
       ret << index.identifier().toString();
   }
 
@@ -610,7 +610,7 @@
 
   bool first = true;
   if(m_index) {
-    FOREACH_FUNCTION(IndexedIdentifier index, cd->identifiers)
+    FOREACH_FUNCTION(const IndexedIdentifier& index, cd->identifiers)
     {
       if( !first )
         ret += "::";
@@ -620,7 +620,7 @@
       ret += index.identifier().toString();
     }
   }else{
-    FOREACH_FUNCTION(IndexedIdentifier index, dd->identifiers)
+    FOREACH_FUNCTION(const IndexedIdentifier& index, dd->identifiers)
     {
       if( !first )
         ret += "::";
--- trunk/extragear/sdk/kdevplatform/language/duchain/importers.cpp #1112200:1112201
@@ -182,7 +182,7 @@
   
   if(index) {
     const ImportersItem* repositoryItem = d->m_importers.itemFromIndex(index);
-    FOREACH_FUNCTION(IndexedDUContext decl, repositoryItem->importers)
+    FOREACH_FUNCTION(const IndexedDUContext& decl, repositoryItem->importers)
       ret.append(decl);
   }
   
--- trunk/extragear/sdk/kdevplatform/language/duchain/topducontext.cpp \
#1112200:1112201 @@ -209,7 +209,7 @@
         addImportedContextRecursively(top, false, true);
       }
     }
-    FOREACH_FUNCTION(IndexedDUContext importer, m_ctxt->d_func()->m_importers) {
+    FOREACH_FUNCTION(const IndexedDUContext& importer, \
m_ctxt->d_func()->m_importers) {  \
if(DUChain::self()->isInMemory(importer.topContextIndex())) {  \
Q_ASSERT(importer.context());  TopDUContext* top = importer.context()->topContext();
@@ -935,7 +935,7 @@
   ENSURE_CAN_READ
 
 #ifdef DEBUG_SEARCH
-  FOREACH_ARRAY(SearchItem::Ptr idTree, identifiers)
+  FOREACH_ARRAY(const SearchItem::Ptr& idTree, identifiers)
       foreach(const QualifiedIdentifier &id, idTree->toList())
         kDebug() << "searching item" << id.toString();
 #endif
@@ -1052,7 +1052,7 @@
               return false;
           }else{
             //Create an identifiers where namespace-alias part is replaced with the \
                alias target
-            FOREACH_ARRAY(SearchItem::Ptr item, identifier->next)
+            FOREACH_ARRAY(const SearchItem::Ptr& item, identifier->next)
               if(!applyAliases(importIdentifier, item, accept, position, \
canBeNamespace, &info, recursionDepth+1))  return false;
           }
@@ -1066,7 +1066,7 @@
       if(!accept(id)) //We're at the end of a qualified identifier, accept it
         return false;
     } else {
-      FOREACH_ARRAY(SearchItem::Ptr next, identifier->next)
+      FOREACH_ARRAY(const SearchItem::Ptr& next, identifier->next)
         if(!applyAliases(id, next, accept, position, canBeNamespace, 0, \
recursionDepth+1))  return false;
     }
@@ -1137,7 +1137,7 @@
 {
   QualifiedIdentifier emptyId;
   
-  FOREACH_ARRAY(SearchItem::Ptr item, identifiers)
+  FOREACH_ARRAY(const SearchItem::Ptr& item, identifiers)
     applyAliases(emptyId, item, acceptor, position, canBeNamespace, 0, 0);
 }
 
--- trunk/extragear/sdk/kdevplatform/language/duchain/topducontextdynamicdata.cpp \
#1112200:1112201 @@ -183,7 +183,7 @@
      //We only read the most needed stuff, not the whole top-context data
      QByteArray data = file.read(readValue);
      const TopDUContextData* topData = (const TopDUContextData*)data.constData();
-     FOREACH_FUNCTION(IndexedDUContext importer, topData->m_importers)
+     FOREACH_FUNCTION(const IndexedDUContext& importer, topData->m_importers)
       ret << importer;
   }
 
@@ -204,7 +204,7 @@
      //We only read the most needed stuff, not the whole top-context data
      QByteArray data = file.read(readValue);
      const TopDUContextData* topData = (const TopDUContextData*)data.constData();
-     FOREACH_FUNCTION(DUContext::Import import, topData->m_importedContexts)
+     FOREACH_FUNCTION(const DUContext::Import& import, topData->m_importedContexts)
       ret << import.indexedContext();
   }
 
--- trunk/extragear/sdk/kdevplatform/language/duchain/types/functiontype.cpp \
#1112200:1112201 @@ -117,7 +117,7 @@
 {
   ///@todo Don't do the conversion
   QList<AbstractType::Ptr> ret;
-  FOREACH_FUNCTION(IndexedType arg, d_func()->m_arguments)
+  FOREACH_FUNCTION(const IndexedType& arg, d_func()->m_arguments)
     ret << arg.abstractType();
   return ret;
 }
@@ -196,7 +196,7 @@
   uint hash_value = AbstractType::hash();
   hash_value += d_func()->m_returnType.hash() * 859321;
 
-  FOREACH_FUNCTION(IndexedType t, d_func()->m_arguments) {
+  FOREACH_FUNCTION(const IndexedType& t, d_func()->m_arguments) {
     hash_value = (hash_value << 5) - hash_value + t.hash();
   }
 
--- trunk/extragear/sdk/kdevplatform/language/duchain/types/unsuretype.cpp \
#1112200:1112201 @@ -30,7 +30,7 @@
 }
 
 void UnsureType::accept0(KDevelop::TypeVisitor* v) const {
-  FOREACH_FUNCTION(IndexedType type, d_func()->m_types) {
+  FOREACH_FUNCTION(const IndexedType& type, d_func()->m_types) {
     AbstractType::Ptr t = type.abstractType();
     v->visit(t.unsafeData());
   }
@@ -43,7 +43,7 @@
 QString UnsureType::toString() const {
   QString ret = "unsure (";
   bool first = true;
-  FOREACH_FUNCTION(IndexedType type, d_func()->m_types) {
+  FOREACH_FUNCTION(const IndexedType& type, d_func()->m_types) {
     if(!first)
       ret += ", ";
     first = false;
@@ -77,7 +77,7 @@
 
 uint UnsureType::hash() const {
   uint ret = AbstractType::hash();
-  FOREACH_FUNCTION(IndexedType type, d_func()->m_types)
+  FOREACH_FUNCTION(const IndexedType& type, d_func()->m_types)
     ret = 17 * ret + type.hash();
   
   return ret;
--- trunk/extragear/sdk/kdevplatform/language/duchain/uses.cpp #1112200:1112201
@@ -182,7 +182,7 @@
   
   if(index) {
     const UsesItem* repositoryItem = d->m_uses.itemFromIndex(index);
-    FOREACH_FUNCTION(IndexedTopDUContext decl, repositoryItem->uses)
+    FOREACH_FUNCTION(const IndexedTopDUContext& decl, repositoryItem->uses)
       ret.append(decl);
   }
   


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic