diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2019-01-06 09:16:07 -0500 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2019-01-06 09:16:07 -0500 |
commit | 0678c088360752f332752c3eaec551280151c29c (patch) | |
tree | 1a6e1302139557439ef58bc10066d42af200a55a | |
parent | 6a41af4e0169f81386922d6a6065a8b408b77296 (diff) | |
download | egawk-0678c088360752f332752c3eaec551280151c29c.tar.gz egawk-0678c088360752f332752c3eaec551280151c29c.tar.bz2 egawk-0678c088360752f332752c3eaec551280151c29c.zip |
Remove alength array method in favor of accessing table_size directly.
-rwxr-xr-x | ChangeLog | 21 | ||||
-rw-r--r-- | array.c | 10 | ||||
-rw-r--r-- | awk.h | 42 | ||||
-rw-r--r-- | cint_array.c | 1 | ||||
-rw-r--r-- | gawkapi.c | 2 | ||||
-rw-r--r-- | int_array.c | 1 | ||||
-rw-r--r-- | str_array.c | 2 | ||||
-rw-r--r-- | symbol.c | 4 |
8 files changed, 43 insertions, 40 deletions
@@ -1,3 +1,24 @@ +2019-01-06 Andrew J. Schorr <aschorr@telemetry-investments.com> + + Remove pointless alength macro/method that uses a needless + function call indirection to access the table_size value. + + * awk.h (alength, alength_ind): Remove these defines, and also renumber + the array_funcs items after that, and use the <blah>_ind define to + define <blah> instead of repeating the hardcoded numeric value. + (NUM_AFUNCS): Remove unused define. + (assoc_length): Redefine to access table_size directly. + (null_length): Remove prototype. + * array.c (null_array_func): Remove null_length entry. + (null_length): Remove obsolete function. + * cint_array.c (cint_array_func): Remove null_length entry. + * int_array.c (int_array_func): Remove null_length entry. + * str_array.c (str_array_func, env_array_func): Remove null_length + entry. + * gawkapi.c (api_flatten_array_typed): Use the assoc_empty macro to + check for an empty array instead of comparing table_size to 0. + * symbol.c (lookup, check_param_names): Ditto. + 2018-12-21 Arnold D. Robbins <arnold@skeeve.com> * configure.ac: Remove -O only if .developing has 'debug' in it. @@ -40,7 +40,6 @@ static NODE **null_dump(NODE *symbol, NODE *subs); static afunc_t null_array_func[] = { (afunc_t) 0, (afunc_t) 0, - null_length, null_lookup, null_afunc, null_afunc, @@ -150,15 +149,6 @@ null_lookup(NODE *symbol, NODE *subs) return symbol->alookup(symbol, subs); } -/* null_length --- default function for array length interface */ - -NODE ** -null_length(NODE *symbol, NODE *subs ATTRIBUTE_UNUSED) -{ - static NODE *tmp; - tmp = symbol; - return & tmp; -} /* null_afunc --- default function for array interface */ @@ -540,29 +540,26 @@ typedef struct exp_node { #define xarray sub.nodep.rn #define parent_array sub.nodep.x.extra -#define ainit array_funcs[0] #define ainit_ind 0 -#define atypeof array_funcs[1] +#define ainit array_funcs[ainit_ind] #define atypeof_ind 1 -#define alength array_funcs[2] -#define alength_ind 2 -#define alookup array_funcs[3] -#define alookup_ind 3 -#define aexists array_funcs[4] -#define aexists_ind 4 -#define aclear array_funcs[5] -#define aclear_ind 5 -#define aremove array_funcs[6] -#define aremove_ind 6 -#define alist array_funcs[7] -#define alist_ind 7 -#define acopy array_funcs[8] -#define acopy_ind 8 -#define adump array_funcs[9] -#define adump_ind 9 -#define astore array_funcs[10] -#define astore_ind 10 -#define NUM_AFUNCS 11 /* # of entries in array_funcs */ +#define atypeof array_funcs[atypeof_ind] +#define alookup_ind 2 +#define alookup array_funcs[alookup_ind] +#define aexists_ind 3 +#define aexists array_funcs[aexists_ind] +#define aclear_ind 4 +#define aclear array_funcs[aclear_ind] +#define aremove_ind 5 +#define aremove array_funcs[aremove_ind] +#define alist_ind 6 +#define alist array_funcs[alist_ind] +#define acopy_ind 7 +#define acopy array_funcs[acopy_ind] +#define adump_ind 8 +#define adump array_funcs[adump_ind] +#define astore_ind 9 +#define astore array_funcs[astore_ind] /* Node_array_ref: */ #define orig_array lnode @@ -1343,7 +1340,7 @@ DEREF(NODE *r) extern jmp_buf fatal_tag; extern int fatal_tag_valid; -#define assoc_length(a) ((*((a)->alength(a, NULL)))->table_size) +#define assoc_length(a) ((a)->table_size) #define assoc_empty(a) (assoc_length(a) == 0) #define assoc_lookup(a, s) ((a)->alookup(a, s)) @@ -1376,7 +1373,6 @@ extern const char *make_aname(const NODE *symbol); extern const char *array_vname(const NODE *symbol); extern void array_init(void); extern int register_array_func(afunc_t *afunc); -extern NODE **null_length(NODE *symbol, NODE *subs); extern NODE **null_afunc(NODE *symbol, NODE *subs); extern void set_SUBSEP(void); extern NODE *concat_exp(int nargs, bool do_subsep); diff --git a/cint_array.c b/cint_array.c index 05b94400..7db45fd2 100644 --- a/cint_array.c +++ b/cint_array.c @@ -62,7 +62,6 @@ static void cint_print(NODE *symbol); afunc_t cint_array_func[] = { cint_array_init, is_uinteger, - null_length, cint_lookup, cint_exists, cint_clear, @@ -1179,7 +1179,7 @@ api_flatten_array_typed(awk_ext_id_t id, if ( array == NULL || array->type != Node_var_array - || array->table_size == 0 + || assoc_empty(array) || data == NULL) return awk_false; diff --git a/int_array.c b/int_array.c index 069e027d..9f705176 100644 --- a/int_array.c +++ b/int_array.c @@ -49,7 +49,6 @@ static void grow_int_table(NODE *symbol); afunc_t int_array_func[] = { int_array_init, is_integer, - null_length, int_lookup, int_exists, int_clear, diff --git a/str_array.c b/str_array.c index bc6584d2..4972a92b 100644 --- a/str_array.c +++ b/str_array.c @@ -59,7 +59,6 @@ static NODE **str_dump(NODE *symbol, NODE *ndump); afunc_t str_array_func[] = { str_array_init, (afunc_t) 0, - null_length, str_lookup, str_exists, str_clear, @@ -78,7 +77,6 @@ static NODE **env_clear(NODE *symbol, NODE *subs); afunc_t env_array_func[] = { str_array_init, (afunc_t) 0, - null_length, str_lookup, str_exists, env_clear, @@ -106,7 +106,7 @@ lookup(const char *name) n = NULL; for (i = 0; tables[i] != NULL; i++) { - if (tables[i]->table_size == 0) + if (assoc_empty(tables[i])) continue; if ((do_posix || do_traditional) && tables[i] == global_table) @@ -644,7 +644,7 @@ check_param_names(void) bool result = true; NODE n; - if (func_table->table_size == 0) + if (assoc_empty(func_table)) return result; max = func_table->table_size * 2; |