Skip to content

[1.20.1] Optimise BiomeConfig #5514

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

Open
wants to merge 1 commit into
base: 1.20
Choose a base branch
from

Conversation

PaintNinja
Copy link
Contributor

  • Use Map.entry() instead of Pair.of() as the former tells Java it will never be null and never be changed.
  • Use Map.ofEntries() instead of HashMap for the same reason. Reduces memory usage and improves performance by letting the map be exactly sized and strongly immutable.
  • Use the deferred class idiom instead of a couple of mutable fields. Allows the map to be stored in a static final and skips the need for an init check. Static finals are faster to load than normal static fields.

- Use `Map.entry()` instead of `Pair.of()` as the former tells Java it will never be null and never be changed.
- Use `Map.ofEntries()` instead of HashMap for the same reason. Reduces memory usage and improves performance by letting the map be exactly sized and strongly immutable.
- Use the deferred class idiom instead of a couple of mutable fields. Allows the map to be stored in a static final and skips the need for an init check. Static finals are faster to load than normal static fields.
@PaintNinja PaintNinja changed the title [1.20] Optimise BiomeConfig [1.20.1] Optimise BiomeConfig Jun 10, 2025
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.

1 participant