[Kstars-devel] branches/kstars/summer/kdeedu/kstars/kstars/skycomponents

Akarsh Simha akarshsimha at gmail.com
Thu Jun 12 08:15:14 CEST 2008


SVN commit 819781 by asimha:

Fixing a trivial bug in starblocklist.cpp that was preventing
markNext() from being called. This was causing blocks to never be
inserted into the LRU Cache, and thus, cached blocks were never
reused.

With this fix, we achieve a 2x drop in memory usage when limiting
magnitudes at zoom in and zoom out are 10.0 and 6.2!

Leaving the debug statements till we are sure of the code quality.

CCMAIL: kstars-devel at kde.org



 M  +5 -1      starblockfactory.cpp  
 M  +2 -2      starblocklist.cpp  


--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starblockfactory.cpp #819780:819781
@@ -84,6 +84,8 @@
         last = last->prev;
         if( last )
             last->next = NULL;
+        if( freeBlock == first )
+            first = NULL;
         freeBlock->prev = NULL;
         freeBlock->next = NULL;
         return freeBlock;
@@ -131,8 +133,9 @@
     if( !block )
         return false;
 
+    fprintf(stderr, "markFirst()!\n");
     if( !first ) {
-        fprintf(stderr, "Linking in first block!\n");
+        fprintf(stderr, "\tLinking in first block!\n");
         last = first = block;
         first->prev = first->next = NULL;
         first->drawID = drawID;
@@ -165,6 +168,7 @@
 
 bool StarBlockFactory::markNext( StarBlock *after, StarBlock *block ) {
 
+    fprintf(stderr, "markNext()!\n");
     if( !block || !after )
         return false;
 
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starblocklist.cpp #819780:819781
@@ -79,9 +79,9 @@
                 kDebug() << "ERROR: Could not get a new block from StarBlockFactory::getBlock() in trixel " 
                          << trixel << ", while trying to create block #" << nBlocks + 1 << endl;
                 return false;
-                SBFactory->markNext( blocks[nBlocks - 1], blocks[nBlocks] );
-                ++nBlocks;
             }
+            SBFactory->markNext( blocks[nBlocks - 1], blocks[nBlocks] );
+            ++nBlocks;
         }
         fread( &stardata, sizeof( starData ), 1, dataFile );
         // TODO: Implement Byteswapping


More information about the Kstars-devel mailing list