Precompute operator length for JimParseExprOperator, optimize logic
commit69f1b01e204f538283ef575691c35e76b99f25df
authorLauri Kasanen <cand@gmx.com>
Sat, 9 Mar 2013 10:00:33 +0000 (9 12:00 +0200)
committerSteve Bennett <steveb@workware.net.au>
Mon, 11 Mar 2013 23:00:19 +0000 (12 09:00 +1000)
treec62213a45ca4b3647cae10d21086716d84586ed1
parent9d4f23daa022c9ca012fb65606960b64b22febe5
Precompute operator length for JimParseExprOperator, optimize logic

No regressions, no changes in bench.tcl.

JimParseExprOperator was shockingly inefficient, to the point of taking 63% of cpu
in my own app.

It did a linear search over >60 structs, re-computing the string length each time, and
doing a string comparison for each.

This patch pre-computes the operator string length, speeding the function up by two.

Adding the first-letter fast path and evaluating length before strncmp make for
another 2x speedup, making the total speedup 4x.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
jim.c