Commit 264d15c
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 d71ff28 commit 264d15c
2 files changed
+16
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 177 | | |
184 | 178 | | |
185 | 179 | | |
| |||
| 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 | | |
| |||
69 | 64 | | |
70 | 65 | | |
71 | 66 | | |
72 | | - | |
| 67 | + | |
73 | 68 | | |
74 | | - | |
| 69 | + | |
75 | 70 | | |
76 | 71 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
80 | 76 | | |
| 77 | + | |
| 78 | + | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
| |||
227 | 225 | | |
228 | 226 | | |
229 | 227 | | |
230 | | - | |
| 228 | + | |
231 | 229 | | |
232 | 230 | | |
233 | 231 | | |
| |||
259 | 257 | | |
260 | 258 | | |
261 | 259 | | |
262 | | - | |
| 260 | + | |
263 | 261 | | |
264 | 262 | | |
265 | 263 | | |
| |||
288 | 286 | | |
289 | 287 | | |
290 | 288 | | |
291 | | - | |
| 289 | + | |
292 | 290 | | |
293 | 291 | | |
294 | 292 | | |
| |||
345 | 343 | | |
346 | 344 | | |
347 | 345 | | |
348 | | - | |
| 346 | + | |
349 | 347 | | |
350 | 348 | | |
351 | 349 | | |
| |||
438 | 436 | | |
439 | 437 | | |
440 | 438 | | |
441 | | - | |
| 439 | + | |
442 | 440 | | |
443 | | - | |
444 | | - | |
| 441 | + | |
| 442 | + | |
445 | 443 | | |
446 | 444 | | |
447 | 445 | | |
| |||
0 commit comments