From 5e3b817b8134f21fc2db93237e155e98882c8d2f Mon Sep 17 00:00:00 2001 From: Lev Date: Sat, 26 Nov 2022 02:55:00 +0300 Subject: [PATCH] Cleanup --- .../exoplayer2/util/ParsableByteArray.java | 25 +++---------------- .../exoplayer2/text/subrip/SubripDecoder.java | 3 +-- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableByteArray.java b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableByteArray.java index 4a101d82fa..f4c23f7472 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableByteArray.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableByteArray.java @@ -157,11 +157,6 @@ public final class ParsableByteArray { this.position = position; } - /** Resets the current byte offset. */ - public void resetPosition() { - this.position = 0; - } - /** * Returns the underlying array. * @@ -572,8 +567,7 @@ public final class ParsableByteArray { return null; } - boolean isLittleEndian = charset.equals(Charsets.UTF_16LE); - int lineLimit = calculateLineLimitForUtf16(isLittleEndian); + int lineLimit = calculateLineLimitForUtf16(charset.equals(Charsets.UTF_16LE)); if (lineLimit - position >= 2 && isUtf16BOM(peekChar())) { // There's a UTF-16 byte order mark at the start of the line. Discard it. @@ -586,27 +580,14 @@ public final class ParsableByteArray { return line; } - char currentChar; - if(isLittleEndian) { - currentChar = peekLittleEndianChar(); - } else { - currentChar = peekChar(); - } - - if (currentChar == '\r') { + if (peekLittleEndianChar() == '\r' || peekChar() == '\r') { position += 2; if (position == limit) { return line; } } - if(isLittleEndian) { - currentChar = peekLittleEndianChar(); - } else { - currentChar = peekChar(); - } - - if (currentChar == '\n') { + if (peekLittleEndianChar() == '\n' || peekChar() == '\n') { position += 2; } return line; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java b/library/extractor/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java index adf7dab6e4..679fa76e4b 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java @@ -144,10 +144,9 @@ public final class SubripDecoder extends SimpleSubtitleDecoder { /** * Determine UTF encoding of the byte array. It can be UTF-16LE/UTF-16BE * if the byte array contains BOM, or UTF-8 otherwise as the default behavior. - * After it resets the offset in ParsableByteArray * * @param data byte array to determinate UTF encoding. - * @return Determined encoding + * @return determined encoding */ private Charset detectUtfCharset(ParsableByteArray data) { if(data.limit() < 2) {