Caching charset in h(). It's save round 50% over each call by helpers.

This commit is contained in:
Juan Basso 2010-01-19 09:31:27 -02:00 committed by José Lorenzo Rodríguez
parent 22073e3376
commit 6882d96bf8

View file

@ -204,13 +204,19 @@ if (!function_exists('array_combine')) {
if (is_array($text)) { if (is_array($text)) {
return array_map('h', $text); return array_map('h', $text);
} }
if (empty($charset)) {
$charset = Configure::read('App.encoding'); static $defaultCharset = false;
if ($defaultCharset === false) {
$defaultCharset = Configure::read('App.encoding');
if ($defaultCharset === null) {
$defaultCharset = 'UTF-8';
}
} }
if (empty($charset)) { if ($charset) {
$charset = 'UTF-8'; return htmlspecialchars($text, ENT_QUOTES, $charset);
} else {
return htmlspecialchars($text, ENT_QUOTES, $defaultCharset);
} }
return htmlspecialchars($text, ENT_QUOTES, $charset);
} }
/** /**