use more efficient way to determine needed bytes for variable byte

encoding

I experimented with a few branch-free variants, but they were slower
than just using ternary operators and readable code.
This commit is contained in:
2024-04-01 12:44:30 +02:00
parent 6b8e3d2089
commit 452030de5e
2 changed files with 16 additions and 11 deletions

View File

@@ -81,7 +81,7 @@ public class VariableByteEncoderTest {
Assertions.assertEquals(originalValues, decodedValues);
}
public static Stream<Arguments> providerNededBytes() {
public static Stream<Arguments> providerNeededBytes() {
return Stream.of( //
Arguments.of(0, 1), //
Arguments.of(-10, 1), //
@@ -98,7 +98,7 @@ public class VariableByteEncoderTest {
}
@ParameterizedTest
@MethodSource("providerNededBytes")
@MethodSource("providerNeededBytes")
public void testNeededBytes(final long value, final int expectedNeededBytes) {
final int neededBytes = VariableByteEncoder.neededBytes(value);