-
Notifications
You must be signed in to change notification settings - Fork 588
Use BlockPositions internally instead of Locations #4220
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
Use BlockPositions internally instead of Locations #4220
Conversation
Your Pull Request was automatically labelled as: "💡 Performance Optimization" |
Slimefun preview buildA Slimefun preview build is available for testing! https://preview-builds.walshy.dev/download/Slimefun/4220/fc8eae0d
|
Potentially controversial things I want opinions on:
|
Once this PR is ready/in a good state I'll make an additional PR that updates all of the slimefun implementations, tests, etc, that use the old methods to use the new ones |
I'm pretty sure |
The only usages I could find for getrawstorage outside of base SF was headlimiter (which I can PR to fix) and my own project that isn't released. As for getLocations I couldn't find any usages but I could obviously have missed some. The thing with copying it is that it'll use WAY more memory than the old method did since every time the method is called itll create a NEW location instance for every block position. While previously the immutable map would have (I assume) just been references. |
Closure of shame incoming |
me and Idra did major bad napkin math, the memory save is negligible #blame-idra |
Description
BlockStorage & related classes currently use Locations internally instead of BlockPositions. Locations are comprised of a Reference, 3 doubles, and 2 floats, while BlockPositions are comprised of only a WeakReference, and a long.
By switching to using BlockPositions we would save MASSIVELY on memory with the current implementation of BlockStorage.
Once this PR is ready to go and approved I will make a matching PR that updates all of Slimefun's internals to use the new methods instead of the deprecated old ones.
Proposed changes
Checklist
Nonnull
andNullable
annotations to my methods to indicate their behaviour for null values