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

Improve BiomeMask performance #3082

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Improve BiomeMask performance #3082

wants to merge 2 commits into from

Conversation

SirYwell
Copy link
Member

Overview

Description

BiomeMask and biome access generally are rather slow, and a lot of the slowness is caused by inefficient translation and slow contains checks. The adaption from NMS biomes to WE BiomeType can be simplified as we already set the legacy id (= NMS-internal id). The HashSet can be replaced by a boolean array, similar to how BlockMask works.

Submitter Checklist

Preview Give feedback

@SirYwell SirYwell requested a review from a team as a code owner January 19, 2025 17:54
Comment on lines +303 to +314
class BiomeTypeIdCache {
private static final List<BiomeType> byId = create();

private static List<BiomeType> create() {
BiomeType[] array = values().toArray(new BiomeType[0]);
Arrays.sort(array, Comparator.comparing(BiomeType::getLegacyId));
return List.of(array);
}

}
if (legacyId >= 0 && legacyId < BiomeTypeIdCache.byId.size()) {
return BiomeTypeIdCache.byId.get(legacyId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason on using a List instead of an array?

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

Successfully merging this pull request may close these issues.

2 participants