Commit 1ff05e9
committed
[CLEANUP] Don't store array length as a property
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
This change also ensures that the characters are always a (dazzling) array.
And adds a type parameter to `ParserState::setCharset()`,
which was unavoidably required.
Resolves #953.1 parent ee3d57c commit 1ff05e9
1 file changed
+8
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
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