mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Remove some redundant 'throws'; allocate more reasonably sized StringBuffers for performance
git-svn-id: https://zxing.googlecode.com/svn/trunk@1093 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
34607d71ee
commit
e913ff5990
|
@ -105,7 +105,7 @@ public final class AddressBookParsedResult extends ParsedResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayResult() {
|
public String getDisplayResult() {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(100);
|
||||||
maybeAppend(names, result);
|
maybeAppend(names, result);
|
||||||
maybeAppend(pronunciation, result);
|
maybeAppend(pronunciation, result);
|
||||||
maybeAppend(title, result);
|
maybeAppend(title, result);
|
||||||
|
|
|
@ -84,7 +84,7 @@ public final class CalendarParsedResult extends ParsedResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayResult() {
|
public String getDisplayResult() {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(100);
|
||||||
maybeAppend(summary, result);
|
maybeAppend(summary, result);
|
||||||
maybeAppend(start, result);
|
maybeAppend(start, result);
|
||||||
maybeAppend(end, result);
|
maybeAppend(end, result);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public final class EmailAddressParsedResult extends ParsedResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayResult() {
|
public String getDisplayResult() {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(30);
|
||||||
maybeAppend(emailAddress, result);
|
maybeAppend(emailAddress, result);
|
||||||
maybeAppend(subject, result);
|
maybeAppend(subject, result);
|
||||||
maybeAppend(body, result);
|
maybeAppend(body, result);
|
||||||
|
|
|
@ -63,7 +63,7 @@ public final class SMSParsedResult extends ParsedResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayResult() {
|
public String getDisplayResult() {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(100);
|
||||||
maybeAppend(number, result);
|
maybeAppend(number, result);
|
||||||
maybeAppend(via, result);
|
maybeAppend(via, result);
|
||||||
maybeAppend(subject, result);
|
maybeAppend(subject, result);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public final class TelParsedResult extends ParsedResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayResult() {
|
public String getDisplayResult() {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(20);
|
||||||
maybeAppend(number, result);
|
maybeAppend(number, result);
|
||||||
maybeAppend(title, result);
|
maybeAppend(title, result);
|
||||||
return result.toString();
|
return result.toString();
|
||||||
|
|
|
@ -68,7 +68,7 @@ public final class URIParsedResult extends ParsedResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayResult() {
|
public String getDisplayResult() {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(30);
|
||||||
maybeAppend(title, result);
|
maybeAppend(title, result);
|
||||||
maybeAppend(uri, result);
|
maybeAppend(uri, result);
|
||||||
return result.toString();
|
return result.toString();
|
||||||
|
|
|
@ -151,7 +151,7 @@ final class VCardResultParser extends ResultParser {
|
||||||
start = end + 1;
|
start = end + 1;
|
||||||
}
|
}
|
||||||
components[componentIndex] = name.substring(start);
|
components[componentIndex] = name.substring(start);
|
||||||
StringBuffer newName = new StringBuffer();
|
StringBuffer newName = new StringBuffer(100);
|
||||||
maybeAppendComponent(components, 3, newName);
|
maybeAppendComponent(components, 3, newName);
|
||||||
maybeAppendComponent(components, 1, newName);
|
maybeAppendComponent(components, 1, newName);
|
||||||
maybeAppendComponent(components, 2, newName);
|
maybeAppendComponent(components, 2, newName);
|
||||||
|
|
|
@ -77,7 +77,7 @@ final class DecodedBitStreamParser {
|
||||||
|
|
||||||
static DecoderResult decode(byte[] bytes) throws ReaderException {
|
static DecoderResult decode(byte[] bytes) throws ReaderException {
|
||||||
BitSource bits = new BitSource(bytes);
|
BitSource bits = new BitSource(bytes);
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(100);
|
||||||
StringBuffer resultTrailer = new StringBuffer(0);
|
StringBuffer resultTrailer = new StringBuffer(0);
|
||||||
Vector byteSegments = new Vector(1);
|
Vector byteSegments = new Vector(1);
|
||||||
int mode = ASCII_ENCODE;
|
int mode = ASCII_ENCODE;
|
||||||
|
|
|
@ -204,8 +204,7 @@ public final class Detector {
|
||||||
/**
|
/**
|
||||||
* Counts the number of black/white transitions between two points, using something like Bresenham's algorithm.
|
* Counts the number of black/white transitions between two points, using something like Bresenham's algorithm.
|
||||||
*/
|
*/
|
||||||
private ResultPointsAndTransitions transitionsBetween(ResultPoint from, ResultPoint to)
|
private ResultPointsAndTransitions transitionsBetween(ResultPoint from, ResultPoint to) {
|
||||||
throws ReaderException {
|
|
||||||
// See QR Code Detector, sizeOfBlackWhiteBlackRun()
|
// See QR Code Detector, sizeOfBlackWhiteBlackRun()
|
||||||
int fromX = (int) from.getX();
|
int fromX = (int) from.getX();
|
||||||
int fromY = (int) from.getY();
|
int fromY = (int) from.getY();
|
||||||
|
|
|
@ -259,7 +259,7 @@ public final class Code128Reader extends AbstractOneDReader {
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
boolean isNextShifted = false;
|
boolean isNextShifted = false;
|
||||||
|
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(20);
|
||||||
int lastStart = startPatternInfo[0];
|
int lastStart = startPatternInfo[0];
|
||||||
int nextStart = startPatternInfo[1];
|
int nextStart = startPatternInfo[1];
|
||||||
int[] counters = new int[6];
|
int[] counters = new int[6];
|
||||||
|
|
|
@ -99,7 +99,7 @@ public final class Code39Reader extends AbstractOneDReader {
|
||||||
nextStart++;
|
nextStart++;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(20);
|
||||||
int[] counters = new int[9];
|
int[] counters = new int[9];
|
||||||
char decodedChar;
|
char decodedChar;
|
||||||
int lastStart;
|
int lastStart;
|
||||||
|
|
|
@ -59,7 +59,7 @@ final class DecodedBitStreamParser {
|
||||||
|
|
||||||
static DecoderResult decode(byte[] bytes, Version version, ErrorCorrectionLevel ecLevel) throws ReaderException {
|
static DecoderResult decode(byte[] bytes, Version version, ErrorCorrectionLevel ecLevel) throws ReaderException {
|
||||||
BitSource bits = new BitSource(bytes);
|
BitSource bits = new BitSource(bytes);
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(50);
|
||||||
CharacterSetECI currentCharacterSetECI = null;
|
CharacterSetECI currentCharacterSetECI = null;
|
||||||
boolean fc1InEffect = false;
|
boolean fc1InEffect = false;
|
||||||
Vector byteSegments = new Vector(1);
|
Vector byteSegments = new Vector(1);
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class Detector {
|
||||||
* of the three finder patterns.</p>
|
* of the three finder patterns.</p>
|
||||||
*/
|
*/
|
||||||
private float calculateModuleSize(ResultPoint topLeft, ResultPoint topRight,
|
private float calculateModuleSize(ResultPoint topLeft, ResultPoint topRight,
|
||||||
ResultPoint bottomLeft) throws ReaderException {
|
ResultPoint bottomLeft) {
|
||||||
// Take the average
|
// Take the average
|
||||||
return (calculateModuleSizeOneWay(topLeft, topRight) +
|
return (calculateModuleSizeOneWay(topLeft, topRight) +
|
||||||
calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f;
|
calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f;
|
||||||
|
|
|
@ -379,7 +379,7 @@ public class FinderPatternFinder {
|
||||||
* @param j end of possible finder pattern in row
|
* @param j end of possible finder pattern in row
|
||||||
* @return true if a finder pattern candidate was found this time
|
* @return true if a finder pattern candidate was found this time
|
||||||
*/
|
*/
|
||||||
protected boolean handlePossibleCenter(int[] stateCount, int i, int j) throws ReaderException {
|
protected boolean handlePossibleCenter(int[] stateCount, int i, int j) {
|
||||||
int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
|
int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
|
||||||
stateCount[4];
|
stateCount[4];
|
||||||
float centerJ = centerFromEnd(stateCount, j);
|
float centerJ = centerFromEnd(stateCount, j);
|
||||||
|
|
Loading…
Reference in a new issue