You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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-arraysResolves#953.
0 commit comments