diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2020-01-26 20:20:58 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2020-01-26 20:20:58 +0200 |
commit | 455542e5a75843bb16c9e747fb63a8731021bf85 (patch) | |
tree | db68ad5822c27606796db7ca5f30af8082c6e63f | |
parent | 11e6edec3f68a8b4e3e218001e5c6a943aa30f63 (diff) | |
download | egawk-455542e5a75843bb16c9e747fb63a8731021bf85.tar.gz egawk-455542e5a75843bb16c9e747fb63a8731021bf85.tar.bz2 egawk-455542e5a75843bb16c9e747fb63a8731021bf85.zip |
Efficiency improvement.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 21 |
2 files changed, 16 insertions, 10 deletions
@@ -1,3 +1,8 @@ +2020-01-26 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * array.c (sort_up_value_type): Small efficiency tweak. Only + run through the list of other types if both values are not scalars. + 2020-01-24 Arnold D. Robbins <arnold@skeeve.com> * array.c, profile.c, cint_array.c, builtin.c, interpret.h, @@ -1153,7 +1153,6 @@ static int sort_up_value_type(const void *p1, const void *p2) { NODE *n1, *n2; - int n1_pos, n2_pos, i; static const NODETYPE element_types[] = { Node_builtin_func, @@ -1180,19 +1179,21 @@ sort_up_value_type(const void *p1, const void *p2) } /* 2. Non scalars */ - n1_pos = n2_pos = -1; - for (i = 0; element_types[i] != Node_illegal; i++) { - if (n1->type == element_types[i]) - n1_pos = i; + if (n1->type != Node_val || n2->type != Node_val) { + int n1_pos, n2_pos, i; - if (n2->type == element_types[i]) - n2_pos = i; - } + n1_pos = n2_pos = -1; + for (i = 0; element_types[i] != Node_illegal; i++) { + if (n1->type == element_types[i]) + n1_pos = i; - assert(n1_pos != -1 && n2_pos != -1); + if (n2->type == element_types[i]) + n2_pos = i; + } - if (n1->type != Node_val || n2->type != Node_val) + assert(n1_pos != -1 && n2_pos != -1); return (n1_pos - n2_pos); + } /* two scalars */ (void) fixtype(n1); |