Get rid of SplFixedArray
#6576
Labels
BC break
Breaks API compatibility
Category: Core
Related to internal functionality
Type: Cleanup
Removes or deprecates API methods or behaviour
Problem description
SplFixedArray is crap and probably slower than regular arrays in 2024.
Regular arrays with linear indexes are heavily optimized in modern versions of PHP (think packed arrays), so the reasons to use SplFixedArray today are far less than they used to be. In addition, they also suck for static analysis on account of probably having offsets containing
null
due to lack of any way to pre-fill the array.It's also an extra object to lurk in the GC root buffer for no good reason, since every
Chunk
uses it, as well asInventory
and various other things.We'd also be able to get rid of this: https://github.com/pmmp/PocketMine-MP/blob/f7687af337d001ddbcc47b8e773f014a33faa662/tests/phpstan/configs/spl-fixed-array-sucks.neon
and probably a bunch of other errors buried in
actual-problems.neon
Proposed solution
TL;DR: It sucks and we should scrap it.
We can do this without BC breaks in places where
SplFixedArray
wasn't exposed on the API.However, some places do expose it and would require breaks to get the job done, so this is labelled as a BC break.
Alternative solutions that don't require API changes
The text was updated successfully, but these errors were encountered: