Skip to content

Commit f806c19

Browse files
committed
Simplify box_overlap computations.
Given the assumption that a box's high coordinates are not less than its low coordinates, the tests in box_ov() are overly complicated and can be reduced to about half as much work. Since many other functions in geo_ops.c rely on that assumption, there doesn't seem to be a good reason not to use it here. Per discussion of Alexander Korotkov's GiST fix, which was already using the simplified logic (in a non-fuzzy form, but the equivalence holds just as well for fuzzy).
1 parent 3c29b19 commit f806c19

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/backend/utils/adt/geo_ops.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,10 @@ box_overlap(PG_FUNCTION_ARGS)
558558
static bool
559559
box_ov(BOX *box1, BOX *box2)
560560
{
561-
return ((FPge(box1->high.x, box2->high.x) &&
562-
FPle(box1->low.x, box2->high.x)) ||
563-
(FPge(box2->high.x, box1->high.x) &&
564-
FPle(box2->low.x, box1->high.x)))
565-
&&
566-
((FPge(box1->high.y, box2->high.y) &&
567-
FPle(box1->low.y, box2->high.y)) ||
568-
(FPge(box2->high.y, box1->high.y) &&
569-
FPle(box2->low.y, box1->high.y)));
561+
return (FPle(box1->low.x, box2->high.x) &&
562+
FPle(box2->low.x, box1->high.x) &&
563+
FPle(box1->low.y, box2->high.y) &&
564+
FPle(box2->low.y, box1->high.y));
570565
}
571566

572567
/* box_left - is box1 strictly left of box2?

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy