diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-05-09 14:00:42 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-05-26 14:08:57 -0400 |
commit | 68be10f11be6098f5cb19bf373e2c6ff82f93c71 (patch) | |
tree | 50eb89713b23e0c011e8b37c854e640c05318629 /libdimension/dimension | |
parent | 21137f8eaae886c034f62e18e6039cc48f09993e (diff) | |
download | dimension-68be10f11be6098f5cb19bf373e2c6ff82f93c71.tar.xz |
object: Get rid of void *ptr field.
Instead, allow dmnsn_object to be embedded in a larger struct.
This gives a consistent 1% speed boost.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r-- | libdimension/dimension/object.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/libdimension/dimension/object.h b/libdimension/dimension/object.h index 28cc266..4d75582 100644 --- a/libdimension/dimension/object.h +++ b/libdimension/dimension/object.h @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> * * * * This file is part of The Dimension Library. * * * @@ -67,6 +67,12 @@ typedef bool dmnsn_object_intersection_fn(const dmnsn_object *object, typedef bool dmnsn_object_inside_fn(const dmnsn_object *object, dmnsn_vector point); +/** + * Object destruction callback. + * @param[in] object The object to delete. + */ +typedef void dmnsn_object_free_fn(dmnsn_object *object); + /** An object. */ struct dmnsn_object { dmnsn_texture *texture; /**< Surface properties. */ @@ -85,9 +91,7 @@ struct dmnsn_object { dmnsn_object_initialize_fn *initialize_fn; /**< Initialization callback. */ dmnsn_object_intersection_fn *intersection_fn; /**< Intersection callback. */ dmnsn_object_inside_fn *inside_fn; /**< Inside callback. */ - dmnsn_free_fn *free_fn; /**< Destruction callback. */ - - void *ptr; /**< Generic pointer for object info. */ + dmnsn_object_free_fn *free_fn; /**< Destruction callback. */ DMNSN_REFCOUNT; /**< Reference count. */ bool initialized; /**< @internal Whether the object is initialized yet. */ @@ -100,6 +104,12 @@ struct dmnsn_object { dmnsn_object *dmnsn_new_object(void); /** + * Initialize a dmnsn_object field. + * @param[in,out] object The object to initialize. + */ +void dmnsn_init_object(dmnsn_object *object); + +/** * Free an object * @param[in,out] object The object to destroy. */ |