From 835a9bdcbd7365187954ab8a6453a2ab67008c2a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 8 Nov 2010 02:10:35 -0500 Subject: Remove useless array node from color-lists. --- dimension/common.rules | 10 +++------- dimension/realize.c | 7 ++----- tests/dimension/demo.sh | 9 ++++----- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/dimension/common.rules b/dimension/common.rules index 754e063..600ef80 100644 --- a/dimension/common.rules +++ b/dimension/common.rules @@ -575,17 +575,13 @@ PIGMENT_MODIFIERS: /* empty */ { ; COLOR_LIST2: /* empty */ { - dmnsn_astnode list = dmnsn_new_astnode(DMNSN_AST_ARRAY, @$); - $$ = dmnsn_new_astnode1(DMNSN_AST_COLOR_LIST, @$, list); + $$ = dmnsn_new_astnode(DMNSN_AST_COLOR_LIST, @$); } | COLOR { - dmnsn_astnode list = dmnsn_new_astnode1(DMNSN_AST_ARRAY, @$, $1); - $$ = dmnsn_new_astnode1(DMNSN_AST_COLOR_LIST, @$, list); + $$ = dmnsn_new_astnode1(DMNSN_AST_COLOR_LIST, @$, $1); } | COLOR "," COLOR { - dmnsn_astnode list = dmnsn_new_astnode2(DMNSN_AST_ARRAY, @$, - $1, $3); - $$ = dmnsn_new_astnode1(DMNSN_AST_COLOR_LIST, @$, list); + $$ = dmnsn_new_astnode2(DMNSN_AST_COLOR_LIST, @$, $1, $3); } ; diff --git a/dimension/realize.c b/dimension/realize.c index 859919f..c879a23 100644 --- a/dimension/realize.c +++ b/dimension/realize.c @@ -481,13 +481,10 @@ dmnsn_realize_color_list(dmnsn_astnode astnode) { dmnsn_assert(astnode.type == DMNSN_AST_COLOR_LIST, "Expected a color list."); - dmnsn_astnode array; - dmnsn_array_get(astnode.children, 0, &array); - dmnsn_color_map *color_map = dmnsn_new_color_map(); - double n = 0.0, i = 1.0/(dmnsn_array_size(array.children) - 1); - DMNSN_ARRAY_FOREACH (dmnsn_astnode *, entry, array.children) { + double n = 0.0, i = 1.0/(dmnsn_array_size(astnode.children) - 1); + DMNSN_ARRAY_FOREACH (dmnsn_astnode *, entry, astnode.children) { dmnsn_color color = dmnsn_realize_color(*entry); dmnsn_add_color_map_entry(color_map, n, color); n += i; diff --git a/tests/dimension/demo.sh b/tests/dimension/demo.sh index c3d9750..4e0c206 100755 --- a/tests/dimension/demo.sh +++ b/tests/dimension/demo.sh @@ -172,11 +172,10 @@ demo_exp=$(echo -n \ (pattern checker) (pigment-modifiers (color-list - (array - (vector (integer 0) (integer 0) (integer 0) - (integer 0) (integer 0)) - (vector (integer 1) (integer 1) (integer 1) - (integer 0) (integer 0)))))))))' \ + (vector (integer 0) (integer 0) (integer 0) + (integer 0) (integer 0)) + (vector (integer 1) (integer 1) (integer 1) + (integer 0) (integer 0))))))))' \ | tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g') if [ "$demo" != "$demo_exp" ]; then -- cgit v1.2.3