promotional bannermobile promotional banner
premium banner
Optimize performance related to tags

Description

In vanilla MC, TagKey objects are deduplicated upon creation through an Interner, so no multiple identical objects exist (allowing identity comparison via identityHashCode and ==). However, since TagKey is a record class, it automatically generates hashCode and equals methods that compare the internal registry and location, and the Interner relies on these for deduplication. This makes hashCode and equals calls elsewhere slower compared to identity comparison. This mod replaces the Interner with a custom deduplicator and overrides the record-generated hashCode and equals, using identityHashCode and == instead, greatly improving comparison and lookup performance elsewhere while also slightly speeding up creation. Incidentally, ResourceKey has also been switched to this custom deduplicator, improving creation speed and reducing memory usage.

Which areas can be optimized: Tags are used in various places throughout MC, such as items, blocks, fluids, entities, world generation, etc., and they all perform checks on whether they contain a certain tag.