Why Regex Sucks in a Hot Loop

A while back I ripped a regex out of my SQL parser and replaced it with twenty lines of hand-written string scanning. Then I got nervous. Hand-rolling a scanner because you assume regex is slow is exactly the kind of premature optimization I make fun of other people for. So I filed an issue against myself: prove the hand-rolled version is actually faster, or delete it and go back to the regex. Months later I sat down to settle it. The honest regex came back about ninety times slower. And the reason had noth

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论