Skip to content

Commit 0056a57

Browse files
committed
Optimize RegistryDelegate#hashCode()
1 parent a76c7f2 commit 0056a57

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.embeddedt.modernfix.forge.mixin.perf.forge_registry_lambda;
2+
3+
import net.minecraft.resources.ResourceLocation;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.Overwrite;
6+
import org.spongepowered.asm.mixin.Shadow;
7+
8+
@Mixin(targets = {"net/minecraftforge/registries/RegistryDelegate"})
9+
public class RegistryDelegateMixin {
10+
@Shadow private ResourceLocation name;
11+
12+
/**
13+
* @author embeddedt
14+
* @reason avoid allocation in hashCode()
15+
*/
16+
@Overwrite(remap = false)
17+
public int hashCode() {
18+
ResourceLocation name = this.name;
19+
if(name != null) {
20+
return name.hashCode();
21+
} else {
22+
return 0;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)