d4e0a5e68076aafa81d0852705fca8fe90fa19ac
angie
  Fri Dec 2 15:23:04 2022 -0800
Avoid regex when looking for isolate component of each name in tree; just look for slashes and distance between them.  When user uploads names, this saves ~40s.

diff --git src/hg/hgPhyloPlace/phyloPlace.c src/hg/hgPhyloPlace/phyloPlace.c
index 0c23266..8ae9ea4 100644
--- src/hg/hgPhyloPlace/phyloPlace.c
+++ src/hg/hgPhyloPlace/phyloPlace.c
@@ -2509,43 +2509,41 @@
  * to fullName. */
 {
 hashAdd(nameHash, id, fullName);
 char *p = strchr(id, '.');
 if (p)
     {
     *p = '\0';
     hashAdd(nameHash, id, fullName);
     }
 }
 
 static void maybeAddIsolate(struct hash *nameHash, char *name, char *fullName)
 /* If name looks like country/isolate/year and isolate looks sufficiently distinctive
  * then also map isolate to fullName. */
 {
-regmatch_t substrs[2];
-if (regexMatchSubstr(name, "^[A-Za-z _]+/(.*)/[0-9]{4}$", substrs, ArraySize(substrs)))
-    {
-    char isolate[substrs[1].rm_eo - substrs[1].rm_so + 1];
-    regexSubstringCopy(name, substrs[1], isolate, sizeof isolate);
-    if (! isInternalNodeName(isolate, 0) &&
-        (regexMatch(isolate, "[A-Za-z0-9]{4}") ||
-         regexMatch(isolate, "[A-Za-z0-9][A-Za-z0-9]+[-_][A-Za-z0-9][A-Za-z0-9]+")))
+char *firstSlash = strchr(name, '/');
+char *lastSlash = strrchr(name, '/');
+if (firstSlash && lastSlash && (lastSlash - firstSlash) >= 4)
     {
+    int len = strlen(name);
+    char isolate[len+1];
+    safencpy(isolate, sizeof isolate, firstSlash+1, lastSlash - firstSlash - 1);
     hashAdd(nameHash, isolate, fullName);
     }
 }
-}
+
 static void addNameMaybeComponents(struct hash *nameHash, char *fullName, boolean addComponents)
 /* Add entries to nameHash mapping fullName to itself, and components of fullName to fullName.
  * If addComponents and fullName is |-separated name|ID|date, add name and ID to nameHash. */
 {
 char *fullNameHashStored = hashStoreName(nameHash, fullName);
 // Now that we have hash storage for fullName, make it point to itself.
 struct hashEl *hel = hashLookup(nameHash, fullName);
 if (hel == NULL)
     errAbort("Can't look up '%s' right after adding it", fullName);
 hel->val = fullNameHashStored;
 if (addComponents)
     {
     char *words[4];
     char copy[strlen(fullName)+1];
     safecpy(copy, sizeof copy, fullName);