From 11fe0b47f21730e2f955ae63896bce2962af1829 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Thu, 24 Jul 2008 13:25:20 +0000 Subject: Only create function for same expression once --- it.class | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/it.class b/it.class index addcf64..ab56894 100644 --- a/it.class +++ b/it.class @@ -650,7 +650,10 @@ function date($format = "", $stamp = null) */ function map($expression, $array) { - $func = create_function('$k,$v', "return $expression;"); + static $cache = array(); + + if (!($func = $cache[$expression])) + $func = $cache[$expression] = create_function('$k,$v', "return $expression;"); foreach ($array as $k => $v) $result[$k] = $func($k, $v); -- cgit v1.2.3