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

List:       kde-commits
Subject:    branches/kdevelop/3.4
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2007-01-20 1:22:22
Message-ID: 1169256142.229254.15782.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 625373 by zwabel:

oops, I accidentally used reversed logic when implementing the accelerating \
namespace-import mapping stuff. This fixes it, and adds some more debugging-output \
when in verbose mode.

 M  +23 -16    languages/cpp/simpletypenamespace.cpp  
 M  +29 -19    lib/interfaces/hashedstring.cpp  
 M  +4 -2      lib/interfaces/hashedstring.h  


--- branches/kdevelop/3.4/languages/cpp/simpletypenamespace.cpp #625372:625373
@@ -236,7 +236,7 @@
   }
 
   ( *it ).insert( a );
-  ifVerbose( dbg() << "\"" << str() << "\": adding namespace-alias \"" << \
name.name() << ( !symmetric ? "\" -> \"" : "\" = \"" ) << alias.name() << "\"" << \
endl ); +  ifVerbose( dbg() << "\"" << str() << "\": adding namespace-alias \"" << \
name.name() << ( !symmetric ? "\" -> \"" : "\" = \"" ) << alias.name() << "\" \
files:\n[ " << files.print().c_str() << "]\n" << endl );  ifVerbose( if ( \
alias.resolved() ) dbg() << "Resolved type of the imported namespace: " << typeid( \
*alias.resolved() ).name() );  
   if ( name.name().isEmpty() ) {
@@ -260,20 +260,22 @@
   for( std::set<size_t>::const_reverse_iterator it = possibleSlaves.rbegin(); it != \
possibleSlaves.rend(); ++it ) {  //Disable all slaves with higher ids
     SlaveMap::iterator current = m_activeSlaves.find( *it );
-    
-      for( SlaveMap::const_iterator itr = current; itr != m_activeSlaves.end(); ++it \
                ) {
-      if( m_activeSlaveGroups.isDisabled( itr->first ) ) break; //stop searching \
                when hitting the first disabled one(assuming that all behind are \
                disabled too)
-      disabled.push_back( itr->first );
-      m_activeSlaveGroups.disableSet( itr->first );
+    if( current == m_activeSlaves.end() ) {
+      kdDebug( 9007 ) << "ERROR" << endl;
     }
 
+    SlaveDesc& d( current->second );
 
-    SlaveDesc& d( current->second );
-    
     if ( !d.first.first.resolved() ) {
+      for( SlaveMap::const_iterator itr = current; itr != m_activeSlaves.end(); ++it \
) { +        if( m_activeSlaveGroups.isDisabled( itr->first ) ) break; //stop \
searching when hitting the first disabled one(assuming that all behind are disabled \
too) +        disabled.push_back( itr->first );
+        m_activeSlaveGroups.disableSet( itr->first );
+      }
+
       TypeDesc descS = d.first.first;
       size_t id = current->first;
-      TypePointer p = d.second;
+      TypePointer p = d.second; //perspective
 
       HashedStringSet importIncludeFiles = d.first.second;
 
@@ -300,6 +302,7 @@
           desc.resolved()->setMasterProxy( this ); //Possible solution: don't use \
this, simply set the parents of all found members correctly  }
 #endif
+        d.first.first = desc;
       }
     }
   }
@@ -307,7 +310,7 @@
   for( std::list<size_t>::const_iterator it = disabled.begin(); it != \
disabled.end(); ++it ) {  m_activeSlaveGroups.enableSet( *it );
   }
-  
+
   return possibleSlaves;
 }
 
@@ -344,6 +347,7 @@
 }
 
 void SimpleTypeNamespace::addImport( const TypeDesc& import, const IncludeFiles& \
files, TypePointer perspective ) { +  //ifVerbose( dbg() << "
   if ( !perspective ) perspective = this;
   invalidateCache();
   TypeDesc d = import;
@@ -356,10 +360,10 @@
     }
     #endif
   }
-  
+
   m_activeSlaves[ ++m_currentSlaveId ] =  std::make_pair( std::make_pair( d, files ) \
, perspective );  m_activeSlaveGroups.addSet( m_currentSlaveId, files );
-  
+
   if( d.resolved() ) ///Must be called after the above, because it may insert new \
slaves, and the order in m_activeSlaves MUST be preserved  \
d.resolved()->addAliasesTo( this );  }
@@ -375,26 +379,29 @@
 
   std::set<size_t> allSlaves = updateAliases( files );
   SlaveList ret;
-#ifdef IMPORT_DEBUG    
+#ifdef IMPORT_DEBUG
   for ( SlaveList::const_iterator it = m_activeSlaves.begin(); it != \
                m_activeSlaves.end(); ++it ) {
-#ifdef IMPORT_DEBUG    
+#ifdef IMPORT_DEBUG
     ifVerbose( dbg() << "\"" << str() << "\": Checking whether \"" << \
(*it).second.first.first.fullNameChain() << "\" should be imported, current \
include-files: " << files.print().c_str() << "\nNeeded include-files: " << \
(*it).second.first.second.print().c_str() << "\n"; )  #endif
     if ( !(( *it ).second.first.second <= files ) ) {
-#ifdef IMPORT_DEBUG    
+#ifdef IMPORT_DEBUG
       ifVerbose( dbg() << "not imported." );
 #endif
       continue;
     }
-#ifdef IMPORT_DEBUG    
+#ifdef IMPORT_DEBUG
     ifVerbose( dbg() << "imported." << endl );
 #endif
     ret.push_back( *it.second );
   }
 #else
+  ifVerbose( dbg() << str() << " getSlaves() called for \n[ " << \
files.print().c_str() << endl ); +  
   for( std::set<size_t>::const_iterator it = allSlaves.begin(); it != \
allSlaves.end(); ++it ) {  SlaveMap::const_iterator itr = m_activeSlaves.find( *it );
     if( itr != m_activeSlaves.end() ) {
+      ifVerbose( dbg() << str() << "getSlaves() returning " << \
(*itr).second.first.first.fullNameChain() << endl );  ret.push_back( (*itr).second );
     } else {
       kdDebug( 9007 ) << "ERROR in getSlaves()";
--- branches/kdevelop/3.4/lib/interfaces/hashedstring.cpp #625372:625373
@@ -284,8 +284,9 @@
     return stream;
 }
 
-void HashedStringSetGroup::addSet( size_t id, const HashedStringSet& set, bool \
emptyMeansGlobal ) { +void HashedStringSetGroup::addSet( size_t id, const \
HashedStringSet& set ) {  if( set.m_data && !set.m_data->m_files.empty() ) {
+    m_sizeMap[ id ] = set.size();
     for( HashedStringSetData::StringSet::const_iterator it = \
set.m_data->m_files.begin(); it != set.m_data->m_files.end(); ++it ) {  \
GroupMap::iterator itr = m_map.find( *it );  if( itr == m_map.end() ) {
@@ -293,7 +294,7 @@
       }
       itr->second.insert( id );
     }
-  } else if( emptyMeansGlobal ) {
+  } else {
     m_global.insert( id );
   }
 }
@@ -313,6 +314,7 @@
 void HashedStringSetGroup::removeSet( size_t id ) {
   m_disabled.erase( id );
   m_global.erase( id );
+  m_sizeMap.erase( id );
   for( GroupMap::iterator it = m_map.begin(); it != m_map.end(); ++it ) {
     it->second.erase( id );
   }
@@ -321,33 +323,41 @@
 void HashedStringSetGroup::findGroups( HashedStringSet strings, ItemSet& target ) \
const {  bool first = true;
   target.clear();
-  if( !strings.m_data ) return;
-  ItemSet oldCut;
+  if( !strings.m_data ) {
+    std::set_difference( m_global.begin(), m_global.end(), m_disabled.begin(), \
m_disabled.end(), std::insert_iterator<ItemSet>( target, target.end() ) ); +    \
return; +  }
   //This might yet be optimized by sorting the sets according to their size, and \
starting the intersectioning with the smallest ones. +  __gnu_cxx::hash_map<size_t, \
int> hitCounts;  
   for( HashedStringSetData::StringSet::const_iterator it = \
strings.m_data->m_files.begin(); it != strings.m_data->m_files.end(); ++it ) {  \
GroupMap::const_iterator itr = m_map.find( *it );  if( itr == m_map.end() ) {
         //There are no string-sets that include the currently searched for string
-        oldCut = m_global;
-        std::set_difference( oldCut.begin(), oldCut.end(), m_disabled.begin(), \
                m_disabled.end(), std::insert_iterator<ItemSet>( target, target.end() \
                ) );
-        return;
+        continue;
       }
-      target.swap( oldCut );
-      target.clear();
-      if( first ) {
-        first = false;
-        std::set_difference( itr->second.begin(), itr->second.end(), \
m_disabled.begin(), m_disabled.end(), std::insert_iterator<ItemSet>( target, \
                target.end() ) );
-      } else {
-        std::set_intersection( oldCut.begin(), oldCut.end(), itr->second.begin(), \
itr->second.end(), std::insert_iterator<ItemSet>( target, target.end() ) ); +
+      for( ItemSet::const_iterator it2 = itr->second.begin(); it2 != \
itr->second.end(); ++it2 ) { +        __gnu_cxx::hash_map<size_t, int>::iterator v = \
hitCounts.find( *it2 ); +        if( v != hitCounts.end() ) {
+          ++(*v).second;
+        } else {
+          hitCounts[*it2] = 1;
+        }
       }
   }
 
-  target.swap( oldCut );
-  target.clear();
-  std::set_union( oldCut.begin(), oldCut.end(), m_global.begin(), m_global.end(), \
std::insert_iterator<ItemSet>( target, target.end() ) ); +  //Now count together all \
groups that are completely within the given string-set(their hitCount equals their \
size) +  ItemSet found;
+  for( __gnu_cxx::hash_map<size_t, int>::const_iterator it = hitCounts.begin(); it \
!= hitCounts.end(); ++it ) { +    if( (*it).second == (*m_sizeMap.find( (*it).first \
)).second ) +      found.insert( (*it).first );
+  }
+
   
-  target.swap( oldCut );
+  std::set_union( found.begin(), found.end(), m_global.begin(), m_global.end(), \
std::insert_iterator<ItemSet>( target, target.end() ) ); +  
+  target.swap( found );
   target.clear();
-  std::set_difference( oldCut.begin(), oldCut.end(), m_disabled.begin(), \
m_disabled.end(), std::insert_iterator<ItemSet>( target, target.end() ) ); +  \
std::set_difference( found.begin(), found.end(), m_disabled.begin(), \
m_disabled.end(), std::insert_iterator<ItemSet>( target, target.end() ) );  }
--- branches/kdevelop/3.4/lib/interfaces/hashedstring.h #625372:625373
@@ -135,18 +135,20 @@
 class HashedStringSetGroup {
   public:
     typedef std::set<size_t> ItemSet;
-    void addSet( size_t id, const HashedStringSet& set, bool emptyMeansGlobal = true \
); +    void addSet( size_t id, const HashedStringSet& set );
     void enableSet( size_t id );
     bool isDisabled( size_t id ) const;
     void disableSet( size_t id );
     void removeSet( size_t id );
 
-    //Writes the ids of all registered and not disabled HashedStringSet's that \
include the given HashedStringSet efficiently) +    //Writes the ids of all \
registered and not disabled HashedStringSet's that are completely included in the \
given HashedStringSet efficiently)  void findGroups( HashedStringSet strings, \
ItemSet& target ) const;  
   private:
     typedef __gnu_cxx::hash_map<HashedString, ItemSet> GroupMap;
+    typedef __gnu_cxx::hash_map<size_t, size_t> SizeMap;
     GroupMap m_map;
+    SizeMap m_sizeMap;
     ItemSet m_disabled;
     ItemSet m_global;
 };


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

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