From 61241872480da6e6ab4306c8d5c16bb36031bc91 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sun, 7 Oct 2018 06:38:54 +0000 Subject: [PATCH] Refactored QrTemplate to use QrCode.getBit(). --- src/io/nayuki/fastqrcodegen/QrCode.java | 2 +- src/io/nayuki/fastqrcodegen/QrTemplate.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/io/nayuki/fastqrcodegen/QrCode.java b/src/io/nayuki/fastqrcodegen/QrCode.java index a1e71e0..dcd958f 100644 --- a/src/io/nayuki/fastqrcodegen/QrCode.java +++ b/src/io/nayuki/fastqrcodegen/QrCode.java @@ -559,7 +559,7 @@ public final class QrCode { // Returns 0 or 1 based on the i'th bit of x. - private static int getBit(int x, int i) { + static int getBit(int x, int i) { return (x >>> i) & 1; } diff --git a/src/io/nayuki/fastqrcodegen/QrTemplate.java b/src/io/nayuki/fastqrcodegen/QrTemplate.java index 41306d1..9ecbbbd 100644 --- a/src/io/nayuki/fastqrcodegen/QrTemplate.java +++ b/src/io/nayuki/fastqrcodegen/QrTemplate.java @@ -173,7 +173,7 @@ final class QrTemplate { // Draw two copies for (int i = 0; i < 18; i++) { - int bit = (bits >>> i) & 1; + int bit = QrCode.getBit(bits, i); int a = size - 11 + i % 3; int b = i / 3; darkenFunctionModule(a, b, bit); @@ -260,7 +260,7 @@ final class QrTemplate { assert 0 <= x && x < size; assert 0 <= y && y < size; int i = y * size + x; - return (grid[i >>> 5] >>> i) & 1; + return QrCode.getBit(grid[i >>> 5], i); }