src/lib/bigBed.c 1.24

1.24 2009/12/01 05:33:26 kent
Fixing bug in maxItem handling in bigBedIntervalQuery
Index: src/lib/bigBed.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/bigBed.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -b -B -U 4 -r1.23 -r1.24
--- src/lib/bigBed.c	13 Nov 2009 19:02:38 -0000	1.23
+++ src/lib/bigBed.c	1 Dec 2009 05:33:26 -0000	1.24
@@ -666,12 +666,8 @@
 	    }
 
 	while (blockPt < blockEnd)
 	    {
-	    ++itemCount;
-	    if (maxItems > 0 && itemCount > maxItems)
-		break;
-
 	    /* Read next record into local variables. */
 	    bits32 chr = memReadBits32(&blockPt, isSwapped);	// Read and discard chromId
 	    bits32 s = memReadBits32(&blockPt, isSwapped);
 	    bits32 e = memReadBits32(&blockPt, isSwapped);
@@ -686,8 +682,12 @@
 
 	    /* If we're actually in range then copy it into a new  element and add to list. */
 	    if (chr == chromId && rangeIntersection(s, e, start, end) > 0)
 		{
+		++itemCount;
+		if (maxItems > 0 && itemCount > maxItems)
+		    break;
+
 		lmAllocVar(lm, el);
 		el->start = s;
 		el->end = e;
 		if (dy->stringSize > 0)