merged branch arnaud-lb/twig-escape-filter-opt (PR #537)
authorFabien Potencier <fabien.potencier@gmail.com>
Sun, 27 Nov 2011 15:46:10 +0000 (16:46 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Sun, 27 Nov 2011 15:46:10 +0000 (16:46 +0100)
commit0a0febc32bbb7739df790211dcbe806de8d505a8
tree5c1841b5a647be79c9415eeced3fc7e466aeca95
parentfba7f95bd2637af9a75bd0f3c0efb2bbf227ee9f
parent7b8d476ea5e842cf9fb863e180dd86a983949970
merged branch arnaud-lb/twig-escape-filter-opt (PR #537)

Commits
-------

7b8d476 optimized twig_escape_filter

Discussion
----------

Optimized twig_escape_filter

This optimizes the part of twig_escape_filter that checks if the charset is supported by htmlspecialchars.

This uses a static variable to avoid initializing the charsets array each time the function is called; and does a hash lookup instead of array search (saves a function call too).

The optimized version takes 66% less time that the original version on html escaping :) (no difference on js escaping).