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

Slow SubChunk garbage collection check #6574

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

Slow SubChunk garbage collection check #6574

dktapps opened this issue Dec 16, 2024 · 0 comments
Labels
Category: Core Related to internal functionality Easy task Probably really easy to do, good task for first-time contributors Performance Type: Enhancement Contributes features or other improvements to PocketMine-MP

Comments

@dktapps
Copy link
Member

dktapps commented Dec 16, 2024

Problem description

foreach($layer->getPalette() as $p){

getPalette() is expensive on account of building a PHP array on the fly to return to user code.

Proposed solution

This check could just check if getBitsPerBlock() === 0 and if get(0, 0, 0) === emptyBlockId. No foreach required, although collectGarbage() must be called first.

Alternative solutions

I considered that we could add PalettedBlockArray::isUniform(int $value) similar to LightArray, but this seems unnecessary since it's easily doable with user code.

@dktapps dktapps added Category: Core Related to internal functionality Type: Enhancement Contributes features or other improvements to PocketMine-MP Performance Easy task Probably really easy to do, good task for first-time contributors labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Core Related to internal functionality Easy task Probably really easy to do, good task for first-time contributors Performance Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

No branches or pull requests

1 participant