Remove slow Enum.values() access replace by fast method

This commit is contained in:
Willem Cazander 2024-12-28 16:18:11 +01:00
parent 8c8ed675ac
commit 44e5950c3a
2 changed files with 32 additions and 12 deletions

View file

@ -102,20 +102,28 @@ public enum FCDotDEC1604DashE2 {
UNDEFINED__NX26_Z, UNDEFINED__NX26_Z,
UNDEFINED__NX27_AMPERSAND, UNDEFINED__NX27_AMPERSAND,
// Encode 21 bit unicode-1 code point ?? // TODO LIST;
// _RESERVED1_UNICODE1(), // todo move down
// Unicode-4 is 72 bit stroke blocks, which are 12 P6 code points to align.
// _WORD_ESC + _TEST_UNICODE4 + <stroke-amount> + manyStrokeBlocks
// _RESERVED4_UNICODE4(), // todo move down
// //
// Historical glue for ansi codes, TODO: put on P6 index number of '[' and ??? // Encode pie numbers 28 and above !!!
// XXX_ESC_PIE_2(),
// XXX_ESC_PIE_3(),
// XXX_ESC_PIE_4(),
//
// Encode 18 full 18 bit FC word in 6 bit !!!
// XXX_FOUR_CORNER(),
//
// Encode 21 bit unicode-1 code point ???
// XXX_UNICODE1(),
//
// Encode 72 bit Unicode-4 !!!
// XXX_UNICODE4(), // _WORD_ESC + _TEST_UNICODE4 + <stroke-amount> + manyStrokeBlocks
//
// Historical glue for ansi codes ???
// TAG_ANSI_UPPER, // TAG_ANSI_UPPER,
// TAG_ANSI_LOWER, // TAG_ANSI_LOWER,
// TAG_ANSI_C0, // bell,backspace,tab etc,
// //
// used for bell,backspace,tab etc, TODO: fix free index number in current ansi escape codes. // Example VT52 see https://en.wikipedia.org/wiki/ANSI_escape_code
// TAG_ANSI_C0,
//
// TODO: Re-impl simple like VT52 see https://en.wikipedia.org/wiki/ANSI_escape_code
// - ESC [ // - ESC [
// - any number (including none) of "parameter bytes" in the range 0x300x3F (ASCII 09:;<=>?), // - any number (including none) of "parameter bytes" in the range 0x300x3F (ASCII 09:;<=>?),
// - any number of "intermediate bytes" in the range 0x200x2F (ASCII space and !"#$%&'()*+,-./), // - any number of "intermediate bytes" in the range 0x200x2F (ASCII space and !"#$%&'()*+,-./),
@ -129,8 +137,20 @@ public enum FCDotDEC1604DashE2 {
// with terminator codes; // with terminator codes;
// On 6 bit P6DEC system with takes __ESC+TAG_SQUARE_LEFT+__PIE+NX09_I+NX01_A // On 6 bit P6DEC system with takes __ESC+TAG_SQUARE_LEFT+__PIE+NX09_I+NX01_A
// On 18 bit P6DEC system with takes TAG_ANSI_UPPER+__PIE+NX09_I+NX01_A // On 18 bit P6DEC system with takes TAG_ANSI_UPPER+__PIE+NX09_I+NX01_A
//
// TODO: full new impl+cleanup of ANSI-NG for 6 bit real computer terminals !?!
; ;
static final private FCDotDEC1604DashE2[] E2_ALL = values();
private FCDotDEC1604DashE2() { private FCDotDEC1604DashE2() {
} }
static public int length() {
return E2_ALL.length;
}
static public FCDotDEC1604DashE2 indexOf(int idx) {
return E2_ALL[idx];
}
} }

View file

@ -40,7 +40,7 @@ public class FCDotCDC1604DashP6Test {
@Test @Test
public void testValues() throws Exception { public void testValues() throws Exception {
Assertions.assertEquals(64, FCDotCDC1604DashP6.values().length); Assertions.assertEquals(64, FCDotCDC1604DashP6.length());
boolean duplicate = false; boolean duplicate = false;
Map<Byte,FCDotCDC1604DashP6> global = new HashMap<>(); Map<Byte,FCDotCDC1604DashP6> global = new HashMap<>();
for (FCDotCDC1604DashP6 v : FCDotCDC1604DashP6.values()) { for (FCDotCDC1604DashP6 v : FCDotCDC1604DashP6.values()) {