mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-26 15:03:14 +00:00
Cache frequent Enum#values() calls (#86)
This commit is contained in:
1 parent
84d462d8d5
commit
a48f59e0ed
64 files changed
+202
-121
No files matched your search
@@ -19,6 +19,10 @@ public enum FruitSprite implements IIconProvider {
|
||||
Larger,
|
||||
Pear;
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final FruitSprite[] VALUES = values();
|
||||
private BinnieIcon icon;
|
||||
|
||||
public short getIndex() {
|
||||
@@ -29,8 +33,8 @@ public enum FruitSprite implements IIconProvider {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(short texUID) {
|
||||
int index = texUID - 4200;
|
||||
if (index >= 0 && index < values().length) {
|
||||
return values()[index].icon.getIcon();
|
||||
if (index >= 0 && index < VALUES.length) {
|
||||
return VALUES[index].icon.getIcon();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user