diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -954,13 +954,11 @@ static function date($format = "", $stamp = null) */ static function map($code, $array, $p = null) { - static $cache = array(); - if (is_string($code) && it::match('^[\w:]+$', $code) && is_callable($code)) $code .= '($v)'; - if (!is_callable($func = $code) && !($func = $cache[$code])) - $func = $cache[$code] = create_function('$k,$v', "return $code;"); + if (!is_callable($func = $code) && !function_exists($func = "_it_map_" . md5($code))) + eval("function $func(\$k, \$v) { return $code; }"); # Anonymous functions/closures are slower than this (PHP 7.1) $result = is_array($array) ? $array : iterator_to_array($array); foreach (isset($p['keys']) ? it::filter_keys($array, $p['keys']) : $array as $k => $v) |