summaryrefslogtreecommitdiffstats
path: root/bench
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-07 15:59:49 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-07 16:09:22 -0400
commit7b08644490cc1f897f4c327af839f0b2448351c0 (patch)
tree7d4fe3dbb0d2dbe8fef27a46f320eac40ecf7298 /bench
parent03c4f1bb394e6d0bee61a438937e068ccf57e09d (diff)
downloaddimension-7b08644490cc1f897f4c327af839f0b2448351c0.tar.xz
Don't use dynamic memory for dmnsn_intersection's.
Drops us from ~400,000 allocs to ~1000. Oops ><.
Diffstat (limited to 'bench')
-rw-r--r--bench/libdimension/bvst.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/bench/libdimension/bvst.c b/bench/libdimension/bvst.c
index de568d5..dd61a80 100644
--- a/bench/libdimension/bvst.c
+++ b/bench/libdimension/bvst.c
@@ -21,13 +21,13 @@
#include <sandglass.h>
#include <stdlib.h>
-dmnsn_intersection *
-dmnsn_fake_intersection_fn(const dmnsn_object *object, dmnsn_line line)
+bool
+dmnsn_fake_intersection_fn(const dmnsn_object *object, dmnsn_line line,
+ dmnsn_intersection *intersection)
{
- dmnsn_intersection *intersection = dmnsn_new_intersection();
intersection->t = (object->bounding_box.min.z - line.x0.z)/line.n.z;
intersection->texture = object->texture;
- return intersection;
+ return true;
}
void
@@ -104,7 +104,7 @@ main()
{
dmnsn_bvst *tree;
dmnsn_bvst_node *node;
- dmnsn_intersection *intersection;
+ dmnsn_intersection intersection;
dmnsn_line ray;
const unsigned int nobjects = 128;
dmnsn_object *objects[nobjects];
@@ -144,11 +144,10 @@ main()
ray.x0 = dmnsn_new_vector(0.0, 0.0, -2.0);
ray.n = dmnsn_new_vector(0.0, 0.0, 1.0);
- dmnsn_delete_intersection((*objects[0]->intersection_fn)(objects[0], ray));
+ (*objects[0]->intersection_fn)(objects[0], ray, &intersection);
sandglass_bench_noprecache(&sandglass, {
- intersection = dmnsn_bvst_search(tree, ray);
+ dmnsn_bvst_search(tree, ray, &intersection);
});
- dmnsn_delete_intersection(intersection);
printf("dmnsn_bvst_search(): %ld\n", sandglass.grains);
/* dmnsn_bvst_splay() */