Commit 5e3b817b by Lev

Cleanup

parent 184761f7
...@@ -157,11 +157,6 @@ public final class ParsableByteArray { ...@@ -157,11 +157,6 @@ public final class ParsableByteArray {
this.position = position; this.position = position;
} }
/** Resets the current byte offset. */
public void resetPosition() {
this.position = 0;
}
/** /**
* Returns the underlying array. * Returns the underlying array.
* *
...@@ -572,8 +567,7 @@ public final class ParsableByteArray { ...@@ -572,8 +567,7 @@ public final class ParsableByteArray {
return null; return null;
} }
boolean isLittleEndian = charset.equals(Charsets.UTF_16LE); int lineLimit = calculateLineLimitForUtf16(charset.equals(Charsets.UTF_16LE));
int lineLimit = calculateLineLimitForUtf16(isLittleEndian);
if (lineLimit - position >= 2 && isUtf16BOM(peekChar())) { if (lineLimit - position >= 2 && isUtf16BOM(peekChar())) {
// There's a UTF-16 byte order mark at the start of the line. Discard it. // There's a UTF-16 byte order mark at the start of the line. Discard it.
...@@ -586,27 +580,14 @@ public final class ParsableByteArray { ...@@ -586,27 +580,14 @@ public final class ParsableByteArray {
return line; return line;
} }
char currentChar; if (peekLittleEndianChar() == '\r' || peekChar() == '\r') {
if(isLittleEndian) {
currentChar = peekLittleEndianChar();
} else {
currentChar = peekChar();
}
if (currentChar == '\r') {
position += 2; position += 2;
if (position == limit) { if (position == limit) {
return line; return line;
} }
} }
if(isLittleEndian) { if (peekLittleEndianChar() == '\n' || peekChar() == '\n') {
currentChar = peekLittleEndianChar();
} else {
currentChar = peekChar();
}
if (currentChar == '\n') {
position += 2; position += 2;
} }
return line; return line;
......
...@@ -144,10 +144,9 @@ public final class SubripDecoder extends SimpleSubtitleDecoder { ...@@ -144,10 +144,9 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
/** /**
* Determine UTF encoding of the byte array. It can be UTF-16LE/UTF-16BE * 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. * 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. * @param data byte array to determinate UTF encoding.
* @return Determined encoding * @return determined encoding
*/ */
private Charset detectUtfCharset(ParsableByteArray data) { private Charset detectUtfCharset(ParsableByteArray data) {
if(data.limit() < 2) { if(data.limit() < 2) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment