From 7a21db5914dd7a5666e603d66ed3948b659ba2fc Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 8 May 2010 23:21:48 -0600 Subject: New DMNSN_ARRAY_FOREACH() macro, faster than iterating with dmnsn_array_get(). --- dimension/common.rules | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'dimension/common.rules') diff --git a/dimension/common.rules b/dimension/common.rules index 4644627..d897eb3 100644 --- a/dimension/common.rules +++ b/dimension/common.rules @@ -152,11 +152,9 @@ OBJECT: FINITE_SOLID_OBJECT *modifiers = dmnsn_new_astnode(DMNSN_AST_OBJECT_MODIFIERS, @4); dmnsn_copy_children(*modifiers, orig_modifiers); - for (size_t i = 0; i < dmnsn_array_size($4.children); ++i) { - dmnsn_astnode astnode; - dmnsn_array_get($4.children, i, &astnode); - ++*astnode.refcount; - dmnsn_array_push(modifiers->children, &astnode); + DMNSN_ARRAY_FOREACH (dmnsn_astnode *, astnode, $4.children) { + ++*astnode->refcount; + dmnsn_array_push(modifiers->children, astnode); } dmnsn_delete_astnode($4); break; @@ -185,11 +183,9 @@ OBJECT: FINITE_SOLID_OBJECT dmnsn_array_size($$.children) - 1, &modifiers); - for (size_t i = 0; i < dmnsn_array_size($4.children); ++i) { - dmnsn_astnode astnode; - dmnsn_array_get($4.children, i, &astnode); - ++*astnode.refcount; - dmnsn_array_push(modifiers.children, &astnode); + DMNSN_ARRAY_FOREACH (dmnsn_astnode *, astnode, $4.children) { + ++*astnode->refcount; + dmnsn_array_push(modifiers.children, astnode); } dmnsn_delete_astnode($4); -- cgit v1.2.3