WildfireRomeo / WildfireFemaleGenderMod

A Fabric Minecraft Mod - Minecraft's Most Popular Female Gender Mod!
https://modrinth.com/mod/female-gender
GNU Lesser General Public License v3.0
106 stars 62 forks source link

remove texture cache #123

Closed RacoonDog closed 1 year ago

RacoonDog commented 1 year ago

Changes:

The ARMOR_TEXTURE_CACHE only caches the creation of the Identifier object, which only takes a few nanoseconds and is less computationally expensive than the HashMap hashing function.

Benchmark      Mode  Cnt   Score   Error  Units
Main.cache     avgt    3  43.148 ± 1.571  ns/op
Main.no_cache  avgt    3  17.560 ± 2.166  ns/op

Moreover, the ARMOR_TEXTURE_CACHE persistently holds multiple Identifier and String objects, resulting in a maximum memory usage of 1264 bytes in vanilla, possibly more with mods involved.

The changes present in this pull request are also applicable to the forge versions.