f808c044991437f1d2f822d5e5d8d3fee26144a2 angie Wed Sep 1 13:38:14 2010 -0700 Performance fix for drawScaledBoxSampleWithText: fixed unnecessary O(N^2) loop condition -- now it will iterate no more than (winEnd-winStart), at base zoom. diff --git src/hg/hgTracks/cds.c src/hg/hgTracks/cds.c index 6d2eed4..00408b1 100644 --- src/hg/hgTracks/cds.c +++ src/hg/hgTracks/cds.c @@ -74,9 +74,6 @@ int x1, x2, w; x1 = round((double)(chromStart-winStart)*scale) + xOff; x2 = round((double)(chromEnd-winStart)*scale) + xOff; - w = x2-x1; - if (w < 1) - w = 1; if (x2 >= maxPixels) x2 = maxPixels - 1; w = x2-x1; @@ -93,9 +90,12 @@ { int thisX,thisX2; char c[2]; - for (i=0; i<strlen(text); i++) + c[1] = '\0'; + int iMin = min(0, (winStart-chromStart)); + int iMax = max((chromEnd-chromStart), (winEnd-chromStart)); + for (i=iMin; i<iMax; i++) { - sprintf(c,"%c",text[i]); + c[0] = text[i]; thisX = round((double)(chromStart+i-winStart)*scale) + xOff; thisX2 = round((double)(chromStart+1+i-winStart)*scale) + xOff; hvGfxTextCentered(hvg, thisX, y, thisX2-thisX, height,