diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-11-16 17:26:22 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-11-16 17:26:22 -0500 |
commit | b3641516fb858dc003eb47095f8ae25fd352b4e0 (patch) | |
tree | 6640dfb1ed1c0d4fad3fc894fabee19225a7140f /libdimension | |
parent | 78dca8153f802f271b4f2aeca33d967a075e485e (diff) | |
download | dimension-b3641516fb858dc003eb47095f8ae25fd352b4e0.tar.xz |
Add some branch instrumentation from gcov profile.
Diffstat (limited to 'libdimension')
-rw-r--r-- | libdimension/polynomial.c | 2 | ||||
-rw-r--r-- | libdimension/prtree.c | 6 | ||||
-rw-r--r-- | libdimension/sphere.c | 5 |
3 files changed, 7 insertions, 6 deletions
diff --git a/libdimension/polynomial.c b/libdimension/polynomial.c index b1dcc2a..a08318b 100644 --- a/libdimension/polynomial.c +++ b/libdimension/polynomial.c @@ -56,7 +56,7 @@ dmnsn_eliminate_zero_roots(double **poly, size_t *degree) { size_t i; for (i = 0; i <= *degree; ++i) { - if (fabs((*poly)[i]) >= dmnsn_epsilon) { + if (dmnsn_likely(fabs((*poly)[i]) >= dmnsn_epsilon)) { break; } } diff --git a/libdimension/prtree.c b/libdimension/prtree.c index 33cb9a2..2451f6b 100644 --- a/libdimension/prtree.c +++ b/libdimension/prtree.c @@ -612,11 +612,11 @@ dmnsn_prtree_intersection(const dmnsn_prtree *tree, dmnsn_line ray, /* Search the intersection cache */ dmnsn_intersection_cache *cache = dmnsn_get_intersection_cache(tree->id); - if (reset) { + if (dmnsn_unlikely(reset)) { cache->i = 0; } dmnsn_object *cached = NULL, *found = NULL; - if (cache->i < DMNSN_PRTREE_CACHE_SIZE) { + if (dmnsn_likely(cache->i < DMNSN_PRTREE_CACHE_SIZE)) { cached = cache->objects[cache->i]; } if (cached && dmnsn_ray_box_intersection(optline, cached->bounding_box, t)) { @@ -642,7 +642,7 @@ dmnsn_prtree_intersection(const dmnsn_prtree *tree, dmnsn_line ray, } /* Update the cache */ - if (cache->i < DMNSN_PRTREE_CACHE_SIZE) { + if (dmnsn_likely(cache->i < DMNSN_PRTREE_CACHE_SIZE)) { cache->objects[cache->i] = found; ++cache->i; } diff --git a/libdimension/sphere.c b/libdimension/sphere.c index a3f0c90..96bc617 100644 --- a/libdimension/sphere.c +++ b/libdimension/sphere.c @@ -23,7 +23,7 @@ * Spheres. */ -#include "dimension.h" +#include "dimension-internal.h" /** Sphere intersection callback. */ static bool @@ -41,7 +41,8 @@ dmnsn_sphere_intersection_fn(const dmnsn_object *sphere, dmnsn_line l, return false; } else { double t = x[0]; - if (n == 2) + /* Optimize for the case where we're outside the sphere */ + if (dmnsn_likely(n == 2)) t = dmnsn_min(t, x[1]); intersection->t = t; |