From 1e8de4acb4e659dfb52cf00ebf2b6f18eb989b97 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 30 Mar 2021 19:29:56 +0200 Subject: [PATCH] refactor: Minor optimization in Window operation. --- src/Operation/Window.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Operation/Window.php b/src/Operation/Window.php index 01121f5e9..39d1584d3 100644 --- a/src/Operation/Window.php +++ b/src/Operation/Window.php @@ -40,14 +40,10 @@ static function (Iterator $iterator) use ($size): Generator { ++$size; $size *= -1; - /** @psalm-var list $stack */ $stack = []; foreach ($iterator as $key => $current) { - // @todo Should we use Pack ? - $stack[$key] = $current; - - yield $key => $stack = array_slice($stack, $size); + yield $key => $stack = array_slice([...$stack, $current], $size); } }; }