Commit 981464c
authored
[CLEANUP] Don't store array length as a property (#954)
Since PHP 5, if not earlier, the length of an array is internally stored by PHP
and can be accessed in O(1) time.
Maintaining both the array and its length in class properties is error-prone
(particularly regarding possible future code changes).
When used in a loop, `\count($array)` is more repetitively expensive than
`$arrayLength`,
but the latter can be set up as a local variable as and when needed.
Reference:
https://stackoverflow.com/questions/5835241/is-phps-count-function-o1-or-on-for-arrays
Resolves #953.1 parent 5af88d7 commit 981464c
1 file changed
+7
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 47 | | |
53 | 48 | | |
54 | 49 | | |
| |||
75 | 70 | | |
76 | 71 | | |
77 | 72 | | |
78 | | - | |
79 | 73 | | |
80 | 74 | | |
81 | 75 | | |
| |||
225 | 219 | | |
226 | 220 | | |
227 | 221 | | |
228 | | - | |
| 222 | + | |
229 | 223 | | |
230 | 224 | | |
231 | 225 | | |
| |||
257 | 251 | | |
258 | 252 | | |
259 | 253 | | |
260 | | - | |
| 254 | + | |
261 | 255 | | |
262 | 256 | | |
263 | 257 | | |
| |||
286 | 280 | | |
287 | 281 | | |
288 | 282 | | |
289 | | - | |
| 283 | + | |
290 | 284 | | |
291 | 285 | | |
292 | 286 | | |
| |||
343 | 337 | | |
344 | 338 | | |
345 | 339 | | |
346 | | - | |
| 340 | + | |
347 | 341 | | |
348 | 342 | | |
349 | 343 | | |
| |||
436 | 430 | | |
437 | 431 | | |
438 | 432 | | |
439 | | - | |
| 433 | + | |
440 | 434 | | |
441 | | - | |
442 | | - | |
| 435 | + | |
| 436 | + | |
443 | 437 | | |
444 | 438 | | |
445 | 439 | | |
| |||
0 commit comments