Tiny code adjustments from inspection

git-svn-id: https://zxing.googlecode.com/svn/trunk@1041 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-08-25 21:29:39 +00:00
parent 46640620e9
commit c02bd97b6a
6 changed files with 29 additions and 40 deletions

View file

@ -96,7 +96,7 @@ public final class Result {
return "[" + rawBytes.length + " bytes]";
} else {
return text;
}
}
}
}

View file

@ -52,10 +52,7 @@ final class URIResultParser extends ResultParser {
}
int period = uri.indexOf('.');
// Look for period in a domain but followed by at least a two-char TLD
if (period >= uri.length() - 2) {
return false;
}
return period >= 0 || uri.indexOf(':') >= 0;
return period < uri.length() - 2 && (period >= 0 || uri.indexOf(':') >= 0);
}
}

View file

@ -51,11 +51,11 @@ public final class Version {
// Calculate the total number of codewords
int total = 0;
int ecCodewords = ecBlocks.ecCodewords;
ECB[] ecbArray = ecBlocks.ecBlocks;
int ecCodewords = ecBlocks.getECCodewords();
ECB[] ecbArray = ecBlocks.getECBlocks();
for (int i = 0; i < ecbArray.length; i++) {
ECB ecBlock = ecbArray[i];
total += ecBlock.count * (ecBlock.dataCodewords + ecCodewords);
total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords);
}
this.totalCodewords = total;
}

View file

@ -51,40 +51,32 @@ public final class ByQuadrantReader implements Reader {
int halfWidth = width / 2;
int halfHeight = height / 2;
{
BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight);
try {
return delegate.decode(topLeft, hints);
} catch (ReaderException re) {
// continue
}
BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight);
try {
return delegate.decode(topLeft, hints);
} catch (ReaderException re) {
// continue
}
{
BinaryBitmap topRight = image.crop(halfWidth, 0, width, halfHeight);
try {
return delegate.decode(topRight, hints);
} catch (ReaderException re) {
// continue
}
BinaryBitmap topRight = image.crop(halfWidth, 0, width, halfHeight);
try {
return delegate.decode(topRight, hints);
} catch (ReaderException re) {
// continue
}
{
BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, height);
try {
return delegate.decode(bottomLeft, hints);
} catch (ReaderException re) {
// continue
}
BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, height);
try {
return delegate.decode(bottomLeft, hints);
} catch (ReaderException re) {
// continue
}
{
BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, width, height);
try {
return delegate.decode(bottomRight, hints);
} catch (ReaderException re) {
// continue
}
BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, width, height);
try {
return delegate.decode(bottomRight, hints);
} catch (ReaderException re) {
// continue
}
int quarterWidth = halfWidth / 2;

View file

@ -190,7 +190,7 @@ final class BitMatrixParser {
for (int i = 0; i < width; i += MODULES_IN_SYMBOL) {
for (int mask = MODULES_IN_SYMBOL - 1; mask >= 0; mask--) {
if (rowCounters[i + (MODULES_IN_SYMBOL - 1 - mask)] >= rowHeight >>> 1) {
symbol |= 1 << mask;
symbol |= 1L << mask;
}
}
if (columnNumber > 0) {
@ -305,7 +305,7 @@ final class BitMatrixParser {
* @param symbol
* @return the codeword corresponding to the symbol.
*/
private int getCodeword(long symbol) {
private static int getCodeword(long symbol) {
long sym = symbol;
sym &= 0x3ffff;
int i = findCodewordIndex(sym);

View file

@ -138,9 +138,9 @@ final class DecodedBitStreamParser {
*/
private static int textCompaction(int[] codewords, int codeIndex, StringBuffer result) {
// 2 character per codeword
int[] textCompactionData = new int[codewords[0] * 2];
int[] textCompactionData = new int[codewords[0] << 1];
// Used to hold the byte compaction value if there is a mode shift
int[] byteCompactionData = new int[codewords[0] * 2];
int[] byteCompactionData = new int[codewords[0] << 1];
int index = 0;
int code = 0;