Skip to content

Commit b9b3f2c

Browse files
rijnbclaude
andcommitted
perf: A2 — reorder fitsInsideBoundaries to test longitude first
Most territory rectangles are narrower in longitude than in latitude relative to their bounding ranges, so testing longitude first short- circuits faster on the typical reject case. time ./unittest (best of 3, user): baseline = 114.13s after A2 = 121.10s delta = -6.11% cumulative (regression vs baseline) Note: result is slower than A1 (T2=112.21s); the lon-first ordering did not yield a speedup on this benchmark — likely because isInRange carries more overhead than the simple comparison it replaces. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 430bbba commit b9b3f2c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

mapcodelib/mapcoder.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,9 @@ static int isInRange(int lonMicroDeg, const int minLonMicroDeg, const int maxLon
602602
static int fitsInsideBoundaries(const Point32* coord32, const TerritoryBoundary* b) {
603603
ASSERT(coord32);
604604
ASSERT(b);
605-
return (b->miny <= coord32->latMicroDeg &&
606-
coord32->latMicroDeg < b->maxy &&
607-
isInRange(coord32->lonMicroDeg, b->minx, b->maxx));
605+
return (isInRange(coord32->lonMicroDeg, b->minx, b->maxx) &&
606+
b->miny <= coord32->latMicroDeg &&
607+
coord32->latMicroDeg < b->maxy);
608608
}
609609

610610

0 commit comments

Comments
 (0)