f05bd698ed7a90ffc44565b5a8a4b128cbf05083 braney Thu Sep 8 16:14:07 2016 -0700 optimization to avoid worrying about overlapping map boxes. diff --git src/hg/hgTracks/imageV2.c src/hg/hgTracks/imageV2.c index 96e1ede..3c2a372 100644 --- src/hg/hgTracks/imageV2.c +++ src/hg/hgTracks/imageV2.c @@ -376,42 +376,61 @@ return map->items; } struct mapItem *mapSetItemUpdateOrAdd(struct mapSet *map,char *link,char *title, int topLeftX,int topLeftY,int bottomRightX,int bottomRightY, char *id) // Update or add a single mapItem { struct mapItem *item = mapSetItemFind(map,topLeftX,topLeftY,bottomRightX,bottomRightY); if (item != NULL) return mapSetItemUpdate(map,item,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY, id); else return mapSetItemAdd(map,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY, id); } -struct mapItem *mapSetItemFindOrAdd(struct mapSet *map,char *link,char *title, +struct mapItem *doMapSetItemFindOrAdd(struct mapSet *map,char *link,char *title, int topLeftX,int topLeftY,int bottomRightX,int bottomRightY, char *id) // Finds or adds the map item { struct mapItem *item = mapSetItemFind(map,topLeftX,topLeftY,bottomRightX,bottomRightY); if (item != NULL) return item; else return mapSetItemAdd(map,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY,id); } +struct mapItem *mapSetItemFindOrAdd(struct mapSet *map,char *link,char *title, + int topLeftX,int topLeftY,int bottomRightX,int bottomRightY, + char *id) +// Function to allow conf variable to turn off or on the searching of overlapping +// previous boxes. +{ +static struct mapItem *(*mapFunc)() = NULL; + +if (mapFunc == NULL) + { + if (cfgOption("restoreMapFind")) + mapFunc = doMapSetItemFindOrAdd; + else + mapFunc = mapSetItemAdd; + } + +return (*mapFunc)(map,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY,id); +} + void mapItemFree(struct mapItem **pItem) // frees all memory assocated with a single mapItem { if (pItem != NULL && *pItem != NULL) { struct mapItem *item = *pItem; if (item->title != NULL) freeMem(item->title); if (item->linkVar != NULL) freeMem(item->linkVar); if (item->id != NULL) freeMem(item->id); freeMem(item); *pItem = NULL; }