3a7264f9a458e02a5e28a048151f14034fbe0d3d
tdreszer
  Thu Oct 17 17:46:17 2013 -0700
Speeding up trix file generation by using the mdb and cv lib code.  Redmine #11951
diff --git src/hg/lib/mdb.c src/hg/lib/mdb.c
index b1f2892..dc6993e 100644
--- src/hg/lib/mdb.c
+++ src/hg/lib/mdb.c
@@ -1838,30 +1838,63 @@
                 struct mdbLeafObj *leafObj = NULL;
                 for (leafObj=limbVal->objs;leafObj!=NULL;leafObj=leafObj->next)
                     {
                     if (leafObj->obj != NULL)
                         count++;
                     }
                 }
             }
         }
     }
 return count;
 }
 
 // ----------------- Utilities -----------------
 
+struct hash *mdbObjsHash(struct mdbObj *mdbObjs)
+// Returns a hash object for this set of mdbObjs, keyed on the obj.
+// WARNING: any changes to the members of the mdbObjs list may lead to invalid pointers in the hash
+{
+if (mdbObjs == NULL)
+    return NULL;
+
+struct hash *objsHash = hashNew(8);
+struct mdbObj *mdbObj = mdbObjs;
+for (;mdbObj!=NULL;mdbObj=mdbObj->next)
+    {
+    hashAdd(objsHash, mdbObj->obj, mdbObj);
+    }
+return objsHash;
+}
+
+struct mdbObj *mdbObjLookUp(struct hash *mdbObjsHash, char *obj)
+// Returns an mdbObj from the objsHash
+// WARNING: any changes to the members of the mdbObjs list used to make the mdbObjsHash
+// may lead to invalid pointers in the hash
+{
+if (mdbObjsHash == NULL || obj == NULL)
+    return NULL;
+
+return hashFindVal(mdbObjsHash,obj);
+}
+
+void mdbObjsHashFree(struct hash **pMdbObjsHash)
+// Frees an mdbObjs hash.
+{
+hashFree(pMdbObjsHash);
+}
+
 struct mdbVar *mdbObjFind(struct mdbObj *mdbObj, char *var)
 // Finds the mdbVar associated with the var or returns NULL
 {
 if (mdbObj == NULL)
     return NULL;
 
 struct mdbVar *mdbVar = NULL;
 if (mdbObj->varHash != NULL)
     mdbVar = hashFindVal(mdbObj->varHash,var); // case sensitive (unfortunately)
 else
     {
     for (mdbVar=mdbObj->vars;mdbVar!=NULL;mdbVar=mdbVar->next)
         {
         if (sameWord(var,mdbVar->var)) // case insensitive
             break;