From 7b08644490cc1f897f4c327af839f0b2448351c0 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 7 Apr 2010 15:59:49 -0400 Subject: Don't use dynamic memory for dmnsn_intersection's. Drops us from ~400,000 allocs to ~1000. Oops ><. --- bench/libdimension/bvst.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'bench/libdimension/bvst.c') 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 #include -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() */ -- cgit v1.2.3