Open jlp765 opened 9 months ago
thanks (I'll check on this when I get back to mawk - currently on xterm...)
In a quick check, the suggested change results in some test-failures. I'll come back to this when I can spend a day or two (at the moment am just working on simple changes for a maintenance release).
Currently gawk (v5.0.1) is about twice as quick as mawk (v1.3.4) for
mawk 'BEGIN{ while(i<1000000){ x[""i]=""i++;} print(x["0"])}'
When forced to use integer indexes, mawk is faster (or comparable to) gawk:
mawk 'BEGIN{i=0; while(i<1000000){ x[i]=i++;} print(x[0])}'
This first example is doing two "wrong" things:
variable i
is not being initialised as an integer, so initially is defaulting to an uninitialized type (internally calls the slowerfind_by_sval()
function)thanvariable x
are being forced to be strings which makes it slow (internally calls the slowerfind_by_sval()
function)The code can be improved to be consistently faster by modifying the default case option of
array_find()
to identify "string" indexes that are actually integer values, and callfind_by_ival()
rather thanfind_by_sval()
e.g. (
array.c
)For minimal testing it works OK, but maybe there exists
where the cell string value of
cp
converts to a zero valued
, then it would result in incorrectly treating a string index as an integer index.Anyway, hope this helps.