simplify matchplus and matchstar
matchplus can be simplified by only modifying matchlength once the complete match is successful. This means it doesn't have to rewind matchlength as it iterates through each possible matchpattern. This also means it keeps matchlength unmodified if it doesn't return a match. Because of this last part, this also means that matchstar can leverage matchplus which reduces it to single line of code return matchplus(...) || matchpattern(..).
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.