summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2022-10-03 08:44:55 +0200
committerChristian Schneider2022-10-03 08:44:55 +0200
commit6d488d7acdacfa8ac477da0afe5175ef9d98dfbe (patch)
tree82be199abe775bc01989d5fd1482936a1e7638ac
parent1d3c9c36e615598fe84e813dfa920616c6d19204 (diff)
downloaditools-6d488d7acdacfa8ac477da0afe5175ef9d98dfbe.tar.gz
itools-6d488d7acdacfa8ac477da0afe5175ef9d98dfbe.tar.bz2
itools-6d488d7acdacfa8ac477da0afe5175ef9d98dfbe.zip
Fix it::map with generators: Avoid iterating over generator twice
-rw-r--r--it.class2
1 files changed, 1 insertions, 1 deletions
diff --git a/it.class b/it.class
index 2079e84..c7d43cb 100644
--- a/it.class
+++ b/it.class
@@ -1111,7 +1111,7 @@ static function map($code, $array, $p = null)
{
$func = self::createfunc($code);
$result = is_array($array) ? $array : iterator_to_array($array);
- foreach (isset($p['keys']) ? it::filter_keys($array, $p['keys']) : $array as $k => $v)
+ foreach (isset($p['keys']) ? it::filter_keys($result, $p['keys']) : $result as $k => $v)
$result[$k] = $func($k, $v);
return (array)$result;