Le 29/05/13 16:21, Tyler Romeo a écrit :
So I ran a brief benchmark on my vagrant instance recently (nothing fancy, just 50,000 iterations of a single line of code), and I found that htmlspecialchars() performs *significantly* faster than strtr() (a difference of like 37%).
Html::element (and other places in the Html class) prefer using strtr() with a manual list of some elements rather than htmlspecialchars(). The reasoning behind this (I think) is do make the output document slightly smaller by a few bytes by not escaping unnecessary items.
So my question is if the byte reduction is really worth it, or if we would rather have a 37% reduction in escaping speed?
I wrote a dumb benchmarking class a while ago under maintenance/benchmarks feel free to add one there.
The original code seems to be by Aryeh in 0120d492b and mentioned indeed "we" liked the size difference.
I would go for speed, that might also makes the code simpler.