diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-02-08 18:26:08 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-02-08 18:26:08 -0500 |
commit | f806c191a3d5faa1af1e5032d394fc6c5f93df86 (patch) | |
tree | 3832482c3db41ba6e640209ba499b6c94fc1d782 /src/backend/utils/adt/geo_ops.c | |
parent | 3c29b196b0ce46662cb9bb7a1f91079fbacbcabb (diff) | |
download | postgresql-f806c191a3d5faa1af1e5032d394fc6c5f93df86.tar.gz postgresql-f806c191a3d5faa1af1e5032d394fc6c5f93df86.zip |
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).
Diffstat (limited to 'src/backend/utils/adt/geo_ops.c')
-rw-r--r-- | src/backend/utils/adt/geo_ops.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index c899e80b35a..ad18cf07e7d 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -558,15 +558,10 @@ box_overlap(PG_FUNCTION_ARGS) static bool box_ov(BOX *box1, BOX *box2) { - return ((FPge(box1->high.x, box2->high.x) && - FPle(box1->low.x, box2->high.x)) || - (FPge(box2->high.x, box1->high.x) && - FPle(box2->low.x, box1->high.x))) - && - ((FPge(box1->high.y, box2->high.y) && - FPle(box1->low.y, box2->high.y)) || - (FPge(box2->high.y, box1->high.y) && - FPle(box2->low.y, box1->high.y))); + return (FPle(box1->low.x, box2->high.x) && + FPle(box2->low.x, box1->high.x) && + FPle(box1->low.y, box2->high.y) && + FPle(box2->low.y, box1->high.y)); } /* box_left - is box1 strictly left of box2? |