Skip to content
Permalink
Browse files

A micro optimization of h()

In most cases, the first argument of h() will be a string.
  • Loading branch information...
chinpei215 committed Jul 10, 2014
1 parent 106d4ef commit 1a58b76e4269caab667478fbca5d5c03a6686895
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/Cake/basics.php
@@ -169,7 +169,9 @@ function sortByKey(&$array, $sortBy, $order = 'asc', $type = SORT_NUMERIC) {
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#h
*/
function h($text, $double = true, $charset = null) {
if (is_array($text)) {
if (is_string($text)) {
//optimize for strings
} elseif (is_array($text)) {
$texts = array();
foreach ($text as $k => $t) {
$texts[$k] = h($t, $double, $charset);

0 comments on commit 1a58b76

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