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

Allow PalettedBlockArray::fromData() to accept raw bytes for the palette #38

Open
dktapps opened this issue Nov 17, 2023 · 0 comments
Open

Comments

@dktapps
Copy link
Member

dktapps commented Nov 17, 2023

Currently, the way we process palette loading is comically inefficient.

We have to convert whatever data we have into a PHP array of integers, which is subsequently converted into a native array after a bunch of slow, non-vectorizable range checks are done on each of the values. In the end, we actually just want a uint32_t[], so we could just accept a raw byte string with a length of a multiple of 4 instead.

This would be significantly faster for FastChunkSerializer, which currently has to involve useless arrays. (It would need to be accompanied by a function to get the palette as a string directly to avoid using pack() and more array conversions.)

For loading from disk, the benefit would be less significant, as we have to build up an array of blockstate IDs from converting NBT anyway, but the benefit of avoiding a throwaway array and a bunch of unnecessary bounds checks would probably be beneficial nonetheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant