diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-06-04 16:16:03 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-06-04 16:16:03 -0400 |
commit | 16ac456e590e11bc2028a697c586a6c7d00fc41a (patch) | |
tree | b961eca096657b5eec2a949e04b1f3fac34dab82 /libdimension-python | |
parent | 270a53ef8d4d009dd79605058b780dc6d1f2ed1a (diff) | |
download | dimension-16ac456e590e11bc2028a697c586a6c7d00fc41a.tar.xz |
csg: Avoid copying the child array for unions.
Diffstat (limited to 'libdimension-python')
-rw-r--r-- | libdimension-python/dimension.pxd | 1 | ||||
-rw-r--r-- | libdimension-python/dimension.pyx | 13 |
2 files changed, 6 insertions, 8 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd index 6579c89..a7b8a53 100644 --- a/libdimension-python/dimension.pxd +++ b/libdimension-python/dimension.pxd @@ -54,6 +54,7 @@ cdef extern from "../libdimension/dimension.h": ctypedef struct dmnsn_array dmnsn_array *dmnsn_new_array(size_t objsize) + dmnsn_array *dmnsn_palloc_array(dmnsn_pool *pool, size_t objsize) void dmnsn_delete_array(dmnsn_array *array) size_t dmnsn_array_size(dmnsn_array *array) diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx index d3f880c..0c4d665 100644 --- a/libdimension-python/dimension.pyx +++ b/libdimension-python/dimension.pyx @@ -1283,17 +1283,14 @@ cdef class Union(Object): if len(objects) < 1: raise TypeError("expected a list of one or more Objects") - cdef dmnsn_array *array = dmnsn_new_array(sizeof(dmnsn_object *)) + cdef dmnsn_array *array = dmnsn_palloc_array(_get_pool(), sizeof(dmnsn_object *)) cdef dmnsn_object *o - try: - for obj in objects: - o = (<Object?>obj)._object - dmnsn_array_push(array, &o) + for obj in objects: + o = (<Object?>obj)._object + dmnsn_array_push(array, &o) - self._object = dmnsn_new_csg_union(_get_pool(), array) - finally: - dmnsn_delete_array(array) + self._object = dmnsn_new_csg_union(_get_pool(), array) Object.__init__(self, *args, **kwargs) |