public static int DetermineContextID(this LiteralContextMode mode, byte mostRecentByte, byte secondRecentByte) { return(mode switch { LiteralContextMode.LSB6 => mostRecentByte & 0x3F, LiteralContextMode.MSB6 => mostRecentByte >> 2, LiteralContextMode.UTF8 => LUT0[mostRecentByte] | LUT1[secondRecentByte], LiteralContextMode.Signed => (LUT2[mostRecentByte] << 3) | LUT2[secondRecentByte], _ => throw new InvalidOperationException("Invalid literal context mode: " + mode) });
// State helpers public int NextLiteralContextID(LiteralContextMode mode) { return(mode.DetermineContextID(LiteralBuffer.Front, LiteralBuffer.Back)); }