Skip to content
Permalink
Browse files

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

  • Loading branch information...
jrbasso authored and lorenzo committed Jan 19, 2010
1 parent 22073e3 commit 6882d96bf8f8b6f602c5c02842eba286f376ad62
Showing with 11 additions and 5 deletions.
  1. +11 −5 cake/basics.php
@@ -204,13 +204,19 @@ function h($text, $charset = null) {
if (is_array($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)) {
$charset = 'UTF-8';
if ($charset) {
return htmlspecialchars($text, ENT_QUOTES, $charset);
} else {
return htmlspecialchars($text, ENT_QUOTES, $defaultCharset);
}
return htmlspecialchars($text, ENT_QUOTES, $charset);
}
/**

0 comments on commit 6882d96

Please sign in to comment.
You can’t perform that action at this time.