mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 23:13:21 +00:00
Cache enum .values() (#248)
Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
1 parent
b46cfbb351
commit
8750005be5
20 files changed
+59
-52
No files matched your search
@@ -19,6 +19,8 @@ public enum RedstoneControlMode implements ICycleEnum {
|
||||
OFF(IconEIO.REDSTONE_MODE_WITHOUT_SIGNAL),
|
||||
NEVER(IconEIO.REDSTONE_MODE_NEVER);
|
||||
|
||||
public static final RedstoneControlMode[] VALUES = values();
|
||||
|
||||
private final IWidgetIcon icon;
|
||||
|
||||
RedstoneControlMode(IWidgetIcon icon) {
|
||||
@@ -63,20 +65,20 @@ public enum RedstoneControlMode implements ICycleEnum {
|
||||
|
||||
public RedstoneControlMode next() {
|
||||
int ord = ordinal();
|
||||
if (ord == values().length - 1) {
|
||||
if (ord == VALUES.length - 1) {
|
||||
ord = 0;
|
||||
} else {
|
||||
ord++;
|
||||
}
|
||||
return values()[ord];
|
||||
return VALUES[ord];
|
||||
}
|
||||
|
||||
public RedstoneControlMode previous() {
|
||||
int ord = ordinal();
|
||||
ord--;
|
||||
if (ord < 0) {
|
||||
ord = values().length - 1;
|
||||
ord = VALUES.length - 1;
|
||||
}
|
||||
return values()[ord];
|
||||
return VALUES[ord];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user