237797ddf3c409a500449847bbdea1c47776ae44
angie
  Fri Aug 25 13:50:48 2017 -0700
Count hashNumEntries only once instead of every time hRefSeqAccForChrom is called.

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index 9690a72..4755bf9 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -5546,24 +5546,27 @@
 {
 static char *firstDb = NULL;
 static struct hash *accHash = NULL;
 static boolean checkExistence = TRUE;
 if (firstDb && !sameString(firstDb, db))
     errAbort("hRefSeqAccForChrom: only works for one db.  %s was passed in earlier, now %s.",
              firstDb, db);
 char *seqAcc = NULL;
 if (checkExistence && !trackHubDatabase(db) && hTableExists(db, "chromAlias"))
     // Will there be a chromAlias for hubs someday??
     {
     firstDb = db;
     struct sqlConnection *conn = hAllocConn(db);
     accHash = sqlQuickHash(conn,
                            NOSQLINJ "select chrom, alias from chromAlias where source = 'refseq'");
+    if (hashNumEntries(accHash) == 0)
+        // No RefSeq accessions -- make accHash NULL
+        hashFree(&accHash);
     hFreeConn(&conn);
     checkExistence = FALSE;
     }
-if (accHash && hashNumEntries(accHash) > 0)
+if (accHash)
     seqAcc = cloneString(hashFindVal(accHash, chrom));
 if (seqAcc == NULL)
     seqAcc = cloneString(chrom);
 return seqAcc;
 }