After several hours of optimizing I've managed to make it so that dmd's lexer is only three times faster. http://hackerpilot.github.com/experimental/std_lexer/images/times.png The funny thing is that compiling with LDC gave a bigger speed boost than any of my code refacatoring.