diff src/getidblock.c @ 360:26c48ea9d896

From Jeffrey Morlan: pst_build_id_ptr reads the Block BTree into a linked list, which pst_getID does a linear scan through. For large PSTs that have millions of blocks, this is extremely slow - almost all time is spent in pst_getID. Since the BTree entries must be in order, this can be dramatically improved by reading into an array and using binary search.
author Carl Byington <carl@five-ten-sg.com>
date Wed, 06 Jul 2016 10:21:08 -0700
parents 201464dd356e
children 5c0ce43c7532
line wrap: on
line diff
--- a/src/getidblock.c	Wed Jul 06 10:20:12 2016 -0700
+++ b/src/getidblock.c	Wed Jul 06 10:21:08 2016 -0700
@@ -130,10 +130,9 @@
         dumper(i_id);
     }
     else {
-        pst_index_ll *ptr = pstfile.i_head;
-        while (ptr) {
-            dumper(ptr->i_id);
-            ptr = ptr->next;
+        size_t i;
+        for (i = 0; i < pstfile.i_count; i++) {
+            dumper(pstfile.i_table[i].i_id);
         }
         dump_desc(pstfile.d_head, NULL);
     }