From 35c72fa8f2ccfd934e54185763c2c207963e1c57 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 1 Aug 2010 14:55:47 -0600 Subject: Optimize PR-tree construction a bit. --- libdimension/dimension/list.h | 8 ++++++++ libdimension/prtree.c | 12 +++++------- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'libdimension') diff --git a/libdimension/dimension/list.h b/libdimension/dimension/list.h index 19ce3c8..bac9740 100644 --- a/libdimension/dimension/list.h +++ b/libdimension/dimension/list.h @@ -123,6 +123,14 @@ dmnsn_list_get(const dmnsn_list_iterator *i, void *obj) memcpy(obj, i->ptr, i->obj_size); } +/* Get a pointer to the i'th object */ +DMNSN_INLINE void * +dmnsn_list_at(const dmnsn_list_iterator *i) +{ + dmnsn_assert(i, "NULL list iterator."); + return i->ptr; +} + /* Set the i'th object, expanding the list if necessary */ DMNSN_INLINE void dmnsn_list_set(dmnsn_list_iterator *i, const void *obj) diff --git a/libdimension/prtree.c b/libdimension/prtree.c index a7a2c26..95f0eaa 100644 --- a/libdimension/prtree.c +++ b/libdimension/prtree.c @@ -73,19 +73,17 @@ enum { DMNSN_ZMAX }; -static double +static inline double dmnsn_priority_get(dmnsn_list_iterator *i, bool is_object, int comparator) { dmnsn_bounding_box box; if (is_object) { - dmnsn_object *object; - dmnsn_list_get(i, &object); - box = object->bounding_box; + dmnsn_object **object = dmnsn_list_at(i); + box = (*object)->bounding_box; } else { - dmnsn_prtree_node *prnode; - dmnsn_list_get(i, &prnode); - box = prnode->bounding_box; + dmnsn_prtree_node **prnode = dmnsn_list_at(i); + box = (*prnode)->bounding_box; } switch (comparator) { -- cgit v1.2.3