Oh, a challenge! :) Even the C like C++ version was still using std::string, which is slow. I attached a faster version to a github issue if anybody is morbidly curious.
I am. Which github issue?
Ah! Part of the article I posted. facepalm
I get paid to write C and C++ but all my best work is still in awk. Absolutely wonderful little language.
Mawk v1.3.4 updated 2013-12-26: http://invisible-island.net/mawk/CHANGES