From 1a58b76e4269caab667478fbca5d5c03a6686895 Mon Sep 17 00:00:00 2001 From: chinpei215 Date: Thu, 10 Jul 2014 20:53:10 +0900 Subject: [PATCH] A micro optimization of h() In most cases, the first argument of h() will be a string. --- lib/Cake/basics.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 4e2588951..509dc8f55 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -169,7 +169,9 @@ if (!function_exists('h')) { * @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);