]> granicus.if.org Git - graphviz/commitdiff
right_of: remove unnecessary bitwise operations
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 10 Sep 2021 01:26:38 +0000 (18:26 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 16 Sep 2021 02:57:25 +0000 (19:57 -0700)
This code was using bitwise operations to substitute for logical boolean
operators. This is sometimes justified, to avoid the short-circuit behavior of
the logical operators that can impair CPU pre-fetching/speculation. However, in
this situation this code is not on a hot path and the bitwise operators were
just making this code harder to read.

lib/neatogen/hedges.c

index 4e0697fcfeba9f6e490ac4d263cef69f10b3a12d..ec003a201bc9b06fae86afd6b2866a469c476b62 100644 (file)
@@ -113,8 +113,7 @@ int right_of(Halfedge * el, Point * p)
        dyp = p->y - topsite->coord.y;
        dxp = p->x - topsite->coord.x;
        fast = 0;
-       if ((!right_of_site & (e->b < 0.0)) |
-           (right_of_site & (e->b >= 0.0))) {
+       if ((!right_of_site && e->b < 0.0) || (right_of_site && e->b >= 0.0)) {
            above = dyp >= e->b * dxp;
            fast = above;
        } else {