Modified some comments to reflect that these objects are thread-safe but not reentrant.
[zxing.git] / core / src / com / google / zxing / qrcode / detector / AlignmentPatternFinder.java
index 1f7ed3b..25e312b 100644 (file)
@@ -32,9 +32,9 @@ import java.util.Vector;
  * pasted and stripped down here for maximum performance but does unfortunately duplicate\r
  * some code.</p>\r
  *\r
- * <p>This class is not thread-safe.</p>\r
+ * <p>This class is thread-safe but not reentrant. Each thread must allocate its own object.\r
  *\r
- * @author srowen@google.com (Sean Owen)\r
+ * @author Sean Owen\r
  */\r
 final class AlignmentPatternFinder {\r
 \r
@@ -45,6 +45,7 @@ final class AlignmentPatternFinder {
   private final int width;\r
   private final int height;\r
   private final float moduleSize;\r
+  private final int[] crossCheckStateCount;\r
 \r
   /**\r
    * <p>Creates a finder that will look in a portion of the whole image.</p>\r
@@ -69,6 +70,7 @@ final class AlignmentPatternFinder {
     this.width = width;\r
     this.height = height;\r
     this.moduleSize = moduleSize;\r
+    this.crossCheckStateCount = new int[3];\r
   }\r
 \r
   /**\r
@@ -146,7 +148,7 @@ final class AlignmentPatternFinder {
       return (AlignmentPattern) possibleCenters.elementAt(0);\r
     }\r
 \r
-    throw new ReaderException("Could not find alignment pattern");\r
+    throw ReaderException.getInstance();\r
   }\r
 \r
   /**\r
@@ -188,7 +190,10 @@ final class AlignmentPatternFinder {
     MonochromeBitmapSource image = this.image;\r
 \r
     int maxI = image.getHeight();\r
-    int[] stateCount = new int[3];\r
+    int[] stateCount = crossCheckStateCount;\r
+    stateCount[0] = 0;\r
+    stateCount[1] = 0;\r
+    stateCount[2] = 0;\r
 \r
     // Start counting up from center\r
     int i = startI;\r