avoid array allocation in Encoder.Mode enum

This commit is contained in:
Sean C. Sullivan 2023-01-22 06:30:06 -08:00
parent 36533a866e
commit 2ce0feba3c

View File

@ -47,8 +47,11 @@ public class Encoder {
*/
FONT;
// see: https://www.gamlor.info/wordpress/2017/08/javas-enum-values-hidden-allocations/
private static final Mode[] ALL_VALUES = values();
public static Mode of(int value) {
return values()[value];
return ALL_VALUES[value];
}
}