Open marler8997 opened 3 years ago
Very interestingly, this change has noticeably improved performance. Before this change, running time ./tests/test2
3 times in a row gave these times:
real 0m4.047s
real 0m5.525s
real 0m3.952s
After this change I'm consistently getting below 3.6:
real 0m3.577s
real 0m3.571s
real 0m3.587s
The run times are much more consistent and it's around a 25% improvement for that test. My guess is that this performance may be due to less code needed to be swapped in and out of the icache? Not sure, but interesting.
matchplus
can be simplified by only modifyingmatchlength
once the complete match is successful. This means it doesn't have to rewindmatchlength
as it iterates through each possiblematchpattern
. This also means it keepsmatchlength
unmodified if it doesn't return a match. Because of this last part, this also means thatmatchstar
can leveragematchplus
which reduces it to single line of codereturn matchplus(...) || matchpattern(..)
.