Skip to content

Commit 40a806c

Browse files
committed
QR Code: reduce encode time by about 8% (mask evaluation)
1 parent 70bdc43 commit 40a806c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ and data.
159159
- Update build toolchain from Java 17 to Java 21 (minimum target runtime remains Java 8)
160160
- SVG and EPS output: round up canvas dimensions when using decimal magnification factor
161161
- MaxiCode: reduce memory use during encoding
162-
- QR Code: reduce encode time by about 15%
162+
- QR Code: reduce encode time by about 25%
163163

164164
#### Okapi Barcode 0.4.6
165165
- QR Code: allow FNC1 escape sequences in user-provided content

src/main/java/uk/org/okapibarcode/backend/QrCode.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,10 +1538,9 @@ private static int evaluate(byte[] eval, int size, int pattern, int best, String
15381538
dark_mods = 0;
15391539
int mask = 0x01 << pattern;
15401540
for (i = 0; i < local.length; i++) {
1541-
if ((eval[i] & mask) != 0) {
1542-
local[i] = 1;
1543-
dark_mods++; // optimization: early prep for test 4 below
1544-
}
1541+
byte val = (byte) ((eval[i] & mask) >> pattern); // 0 or 1
1542+
local[i] = val;
1543+
dark_mods += val; // optimization: early prep for test 4 below
15451544
}
15461545

15471546
encodeInfo.append("Mask ").append(maskToString(pattern)).append(" Penalties: ");

0 commit comments

Comments
 (0)