News for hackers. Stuff that matters.
Re:Stop avoiding regular expressions damn it by buro9 on Sunday May 12, 2013 @10:14AM (#5694292)
You could more than double the performance of the regexp if you did MustCompile just the once rather than within every loop.

MustCompile is generally used to make the regexp a global so that it isn't done over and over.

Just move it out of the loop, as it's really not necessary to compile regular expressions every time you want to match/replace against it.

Re:Stop avoiding regular expressions damn it by Titanous on Sunday May 12, 2013 @10:17AM (#5694313)
It does have the MustCompile outside of the loop. I pasted the wrong link originally.
Re:Stop avoiding regular expressions damn it by buro9 on Sunday May 12, 2013 @10:20AM (#5694321)
Ah, my apology I saw the earlier link.
Re:Stop avoiding regular expressions damn it by Achshar on Sunday May 12, 2013 @10:23AM (#5694336)
If I am reading the chart correctly, doubled performance would still not be enough.
Re:Stop avoiding regular expressions damn it by buro9 on Sunday May 12, 2013 @10:26AM (#5694351)
Absolutely. But the original version linked was twice as slow as need be.

For trivial replacements string manipulation I find is faster and safer (fewer bugs). But there is some threshold of complexity in which regular expressions are both more performant and safer.