mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
c3ce99cce2
commit
95c9edf541
@ -1,6 +1,6 @@
|
||||
// © 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/**
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* Copyright (C) 2005-2016, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
@ -85,13 +85,13 @@ public class CharsetMatch implements Comparable<CharsetMatch> {
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
public String getString(int maxLength) throws java.io.IOException {
|
||||
String result = null;
|
||||
String result;
|
||||
if (fInputStream != null) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
char[] buffer = new char[1024];
|
||||
Reader reader = getReader();
|
||||
int max = maxLength < 0 ? Integer.MAX_VALUE : maxLength;
|
||||
int bytesRead = 0;
|
||||
int bytesRead;
|
||||
|
||||
while ((bytesRead = reader.read(buffer, 0, Math.min(max, 1024))) >= 0) {
|
||||
sb.append(buffer, 0, bytesRead);
|
||||
@ -231,7 +231,7 @@ public class CharsetMatch implements Comparable<CharsetMatch> {
|
||||
// If user gave us a byte array, this is it.
|
||||
private int fRawLength; // Length of data in fRawInput array.
|
||||
|
||||
private InputStream fInputStream = null; // User's input stream, or null if the user
|
||||
private final InputStream fInputStream; // User's input stream, or null if the user
|
||||
// gave us a byte array.
|
||||
|
||||
private final String fCharsetName; // The name of the charset this CharsetMatch
|
||||
|
@ -45,7 +45,7 @@ abstract class CharsetRecog_2022 extends CharsetRecognizer {
|
||||
byte[] seq = escapeSequences[escN];
|
||||
|
||||
if ((textLen - i) < seq.length) {
|
||||
continue checkEscapes;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 1; j < seq.length; j++) {
|
||||
|
@ -159,8 +159,7 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
||||
done = true;
|
||||
return -1;
|
||||
}
|
||||
int byteValue = det.fRawInput[nextIndex++] & 0x00ff;
|
||||
return byteValue;
|
||||
return det.fRawInput[nextIndex++] & 0x00ff;
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,9 +321,9 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
||||
@Override
|
||||
boolean nextChar(iteratedChar it, CharsetDetector det) {
|
||||
it.error = false;
|
||||
int firstByte = 0;
|
||||
int secondByte = 0;
|
||||
int thirdByte = 0;
|
||||
int firstByte;
|
||||
int secondByte;
|
||||
int thirdByte;
|
||||
//int fourthByte = 0;
|
||||
|
||||
buildChar:
|
||||
@ -374,7 +373,7 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
||||
}
|
||||
}
|
||||
|
||||
return (it.done == false);
|
||||
return (!it.done);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -466,10 +465,10 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
||||
@Override
|
||||
boolean nextChar(iteratedChar it, CharsetDetector det) {
|
||||
it.error = false;
|
||||
int firstByte = 0;
|
||||
int secondByte = 0;
|
||||
int thirdByte = 0;
|
||||
int fourthByte = 0;
|
||||
int firstByte;
|
||||
int secondByte;
|
||||
int thirdByte;
|
||||
int fourthByte;
|
||||
|
||||
buildChar:
|
||||
{
|
||||
@ -510,11 +509,10 @@ abstract class CharsetRecog_mbcs extends CharsetRecognizer {
|
||||
}
|
||||
|
||||
it.error = true;
|
||||
break buildChar;
|
||||
}
|
||||
}
|
||||
|
||||
return (it.done == false);
|
||||
return (!it.done);
|
||||
}
|
||||
|
||||
static int[] commonChars =
|
||||
|
@ -263,6 +263,7 @@ abstract class CharsetRecog_sbcs extends CharsetRecognizer {
|
||||
return parser.parse(det, spaceChar);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
int matchIBM420(CharsetDetector det, int[] ngrams, byte[] byteMap, byte spaceChar) {
|
||||
NGramParser_IBM420 parser = new NGramParser_IBM420(ngrams, byteMap);
|
||||
return parser.parse(det, spaceChar);
|
||||
|
Loading…
Reference in New Issue
Block a user