Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of SplFixedArray #6576

Open
dktapps opened this issue Dec 16, 2024 · 0 comments
Open

Get rid of SplFixedArray #6576

dktapps opened this issue Dec 16, 2024 · 0 comments
Labels
BC break Breaks API compatibility Category: Core Related to internal functionality Type: Cleanup Removes or deprecates API methods or behaviour

Comments

@dktapps
Copy link
Member

dktapps commented Dec 16, 2024

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 as Inventory 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

@dktapps dktapps added Category: Core Related to internal functionality BC break Breaks API compatibility Type: Cleanup Removes or deprecates API methods or behaviour labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC break Breaks API compatibility Category: Core Related to internal functionality Type: Cleanup Removes or deprecates API methods or behaviour
Projects
None yet
Development

No branches or pull requests

1 participant