Add @CheckReturnValue
to ParsableByteArray
and ParsableBitArray
This helps encourage usages of `skipXXX()` methods instead of `readXXX()`. PiperOrigin-RevId: 578892379
This commit is contained in:
parent
3253f1b5cd
commit
901f89c456
@ -18,10 +18,12 @@ package androidx.media3.common.util;
|
|||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.errorprone.annotations.CheckReturnValue;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
/** Wraps a byte array, providing methods that allow it to be read as a bitstream. */
|
/** Wraps a byte array, providing methods that allow it to be read as a bitstream. */
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
|
@CheckReturnValue
|
||||||
public final class ParsableBitArray {
|
public final class ParsableBitArray {
|
||||||
|
|
||||||
public byte[] data;
|
public byte[] data;
|
||||||
|
@ -20,6 +20,7 @@ import com.google.common.base.Charsets;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.primitives.Chars;
|
import com.google.common.primitives.Chars;
|
||||||
import com.google.common.primitives.UnsignedBytes;
|
import com.google.common.primitives.UnsignedBytes;
|
||||||
|
import com.google.errorprone.annotations.CheckReturnValue;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -29,6 +30,7 @@ import java.util.Arrays;
|
|||||||
* parsed with the assumption that their constituent bytes are in big endian order.
|
* parsed with the assumption that their constituent bytes are in big endian order.
|
||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
|
@CheckReturnValue
|
||||||
public final class ParsableByteArray {
|
public final class ParsableByteArray {
|
||||||
|
|
||||||
private static final char[] CR_AND_LF = {'\r', '\n'};
|
private static final char[] CR_AND_LF = {'\r', '\n'};
|
||||||
@ -549,7 +551,7 @@ public final class ParsableByteArray {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!charset.equals(Charsets.US_ASCII)) {
|
if (!charset.equals(Charsets.US_ASCII)) {
|
||||||
readUtfCharsetFromBom(); // Skip BOM if present
|
Charset unused = readUtfCharsetFromBom(); // Skip BOM if present
|
||||||
}
|
}
|
||||||
int lineLimit = findNextLineTerminator(charset);
|
int lineLimit = findNextLineTerminator(charset);
|
||||||
String line = readString(lineLimit - position, charset);
|
String line = readString(lineLimit - position, charset);
|
||||||
@ -652,7 +654,7 @@ public final class ParsableByteArray {
|
|||||||
|
|
||||||
private void skipLineTerminator(Charset charset) {
|
private void skipLineTerminator(Charset charset) {
|
||||||
if (readCharacterIfInList(charset, CR_AND_LF) == '\r') {
|
if (readCharacterIfInList(charset, CR_AND_LF) == '\r') {
|
||||||
readCharacterIfInList(charset, LF);
|
char unused = readCharacterIfInList(charset, LF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user