Magnus Manske wrote:
I have checked in the dirtiest hack of the week to
replace that
str_replace :-)
Total rendering time is down 10% on my machine.
Neat! But now that I look at it, it can be sped up a lot just by using a
regular expression:
Original str_replace method:
1 4260.353 4260.353 44.304%
Magnus' scary hack:
1 423.490 423.490 7.385%
Using preg_replace_callback:
1 21.842 21.842 0.354%
(Times are on my PowerBook so not directly comparable to the previously
posted tests from my Linux box.)
I think the str_replace does something stupid like comparing _every one_
of the hundreds of link keys individually to each character position in
the string. :P Using a regexp cuts down the comparisons and doesn't
change behavior.
(The current link replacement code does Weird Things on invalid links
such as things that look like nested links. This needs to be fixed
farther up the chain to avoid creating such monstrosities.)
-- brion vibber (brion @
pobox.com)