247e6b97ca054df01068657d2ffc84d1a48c90ac
aamp
  Sun Apr 3 08:56:50 2011 -0700
Changed HDB stuff in hgLiftOver a bit to reduce database calls. This has not helped speed up the CGI though yet
diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index fd6b25a..0f3479f 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -2467,30 +2467,56 @@
             {
             freez(&db->description);
             db->description = cloneString(next);
             }
         freez(&assembly);
         slAddHead(&dbList, db);
         }
     sqlFreeResult(&sr);
 
     hDisconnectCentral(&conn);
     slReverse(&dbList);
     }
 return dbList;
 }
 
+struct hash *hDbDbHash()
+/* The hashed-up version of the entire dbDb table, keyed on the db */
+/* this is likely better to use than hArchiveOrganism if it's likely to be */
+/* repeatedly called */
+{
+struct hash *dbDbHash = newHash(16);
+struct dbDb *list = hDbDbList();
+struct dbDb *dbdb;
+for (dbdb = list; dbdb != NULL; dbdb = dbdb->next)
+    hashAdd(dbDbHash, dbdb->name, dbdb);
+return dbDbHash; 
+}
+
+struct hash *hDbDbAndArchiveHash()
+/* hDbDbHash() plus the dbDb rows from the archive table */
+{
+struct hash *dbDbHash = newHash(16);
+struct dbDb *archList = hArchiveDbDbList();
+struct dbDb *list = hDbDbList();
+struct dbDb *bothList = slCat(list, archList);
+struct dbDb *dbdb;
+for (dbdb = bothList; dbdb != NULL; dbdb = dbdb->next)
+    hashAdd(dbDbHash, dbdb->name, dbdb);
+return dbDbHash; 
+}
+
 int hDbDbCmpOrderKey(const void *va, const void *vb)
 /* Compare to sort based on order key */
 {
 const struct dbDb *a = *((struct dbDb **)va);
 const struct dbDb *b = *((struct dbDb **)vb);
 
 if (b->orderKey > a->orderKey) return -1;
 else if (b->orderKey < a->orderKey) return 1;
 else return 0;
 }
 
 struct slName *hDbList()
 /* List of all database versions that are online (database
  * names only).  See also hDbDbList. */
 {
@@ -4186,31 +4212,31 @@
 struct dbDb *liftOverDbList = NULL, *dbDb, *nextDbDb;
 struct liftOverChain *chainList = NULL, *chain;
 struct hash *hash = newHash(0), *dbNameHash = newHash(3);
 
 /* Get list of all liftOver chains in central database */
 chainList = liftOverChainListFiltered();
 
 /* Create hash of databases having liftOver chains from this database */
 for (chain = chainList; chain != NULL; chain = chain->next)
     {
     if (!hashFindVal(hash, chain->fromDb))
         hashAdd(hash, chain->fromDb, chain->fromDb);
     }
 
 /* Get list of all current and archived databases */
-regDb = hDbDbListDeadOrAlive();
+regDb = hDbDbList();
 archDb = hArchiveDbDbList();
 allDbList = slCat(regDb, archDb);
 
 /* Create a new dbDb list of all entries in the liftOver hash */
 for (dbDb = allDbList; dbDb != NULL; dbDb = nextDbDb)
     {
     /* current dbDb entries */
     nextDbDb = dbDb->next;
     if (hashFindVal(hash, dbDb->name) && !hashFindVal(dbNameHash, dbDb->name))
 	{
         slAddHead(&liftOverDbList, dbDb);
 	hashAdd(dbNameHash, dbDb->name, dbDb->name);
 	}
     else
         dbDbFree(&dbDb);