@@ -124,7 +124,8 @@ public function subview($selector, bool $readonly = null): ArrayViewInterface
124124 */
125125 public function apply (callable $ mapper ): self
126126 {
127- for ($ i = 0 ; $ i < \count ($ this ); $ i ++) {
127+ $ size = \count ($ this );
128+ for ($ i = 0 ; $ i < $ size ; $ i ++) {
128129 /** @var T $item */
129130 $ item = $ this [$ i ];
130131 $ this [$ i ] = $ mapper ($ item , $ i );
@@ -151,7 +152,8 @@ public function applyWith($data, callable $mapper): self
151152
152153 $ dataView = ArrayView::toView ($ data );
153154
154- for ($ i = 0 ; $ i < \count ($ this ); $ i ++) {
155+ $ size = \count ($ this );
156+ for ($ i = 0 ; $ i < $ size ; $ i ++) {
155157 /** @var T $lhs */
156158 $ lhs = $ this [$ i ];
157159 /** @var U $rhs */
@@ -170,7 +172,8 @@ public function applyWith($data, callable $mapper): self
170172 public function set ($ newValues ): self
171173 {
172174 if (!\is_array ($ newValues ) && !($ newValues instanceof ArrayViewInterface)) {
173- for ($ i = 0 ; $ i < \count ($ this ); $ i ++) {
175+ $ size = \count ($ this );
176+ for ($ i = 0 ; $ i < $ size ; $ i ++) {
174177 $ this [$ i ] = $ newValues ;
175178 }
176179 return $ this ;
@@ -183,7 +186,8 @@ public function set($newValues): self
183186
184187 $ newValuesView = ArrayView::toView ($ newValues );
185188
186- for ($ i = 0 ; $ i < \count ($ this ); $ i ++) {
189+ $ size = \count ($ this );
190+ for ($ i = 0 ; $ i < $ size ; $ i ++) {
187191 $ this [$ i ] = $ newValuesView [$ i ];
188192 }
189193
@@ -195,7 +199,8 @@ public function set($newValues): self
195199 */
196200 public function getIterator (): \Generator
197201 {
198- for ($ i = 0 ; $ i < \count ($ this ); $ i ++) {
202+ $ size = \count ($ this );
203+ for ($ i = 0 ; $ i < $ size ; $ i ++) {
199204 /** @var T $item */
200205 $ item = $ this [$ i ];
201206 yield $ item ;
0 commit comments