Modernize switch statements in FST (#13756)

This commit is contained in:
mrhbj 2024-09-11 15:46:48 +08:00 committed by GitHub
parent ccccf92abd
commit 029c3b5e13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 13 deletions

View File

@ -481,19 +481,13 @@ public final class FST<T> implements Accountable {
} }
INPUT_TYPE inputType; INPUT_TYPE inputType;
final byte t = metaIn.readByte(); final byte t = metaIn.readByte();
switch (t) { inputType =
case 0: switch (t) {
inputType = INPUT_TYPE.BYTE1; case 0 -> INPUT_TYPE.BYTE1;
break; case 1 -> INPUT_TYPE.BYTE2;
case 1: case 2 -> INPUT_TYPE.BYTE4;
inputType = INPUT_TYPE.BYTE2; default -> throw new CorruptIndexException("invalid input type " + t, metaIn);
break; };
case 2:
inputType = INPUT_TYPE.BYTE4;
break;
default:
throw new CorruptIndexException("invalid input type " + t, metaIn);
}
long startNode = metaIn.readVLong(); long startNode = metaIn.readVLong();
long numBytes = metaIn.readVLong(); long numBytes = metaIn.readVLong();
return new FSTMetadata<>(inputType, outputs, emptyOutput, startNode, version, numBytes); return new FSTMetadata<>(inputType, outputs, emptyOutput, startNode, version, numBytes);