Simplified code for 'upward' variable in all language versions, without changing behavior.

pull/11/head
Project Nayuki 8 years ago
parent 21212ba617
commit 7c173b79b4

@ -668,7 +668,7 @@ static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[], i
for (int vert = 0; vert < size; vert++) { // Vertical counter
for (int j = 0; j < 2; j++) {
int x = right - j; // Actual x coordinate
bool upward = ((right & 2) == 0) ^ (x < 6);
bool upward = ((right + 1) & 2) == 0;
int y = upward ? size - 1 - vert : vert; // Actual y coordinate
if (!getModule(qrcode, size, x, y) && i < dataLen * 8) {
bool black = ((data[i >> 3] >> (7 - (i & 7))) & 1) != 0;

@ -348,7 +348,7 @@ void qrcodegen::QrCode::drawCodewords(const std::vector<uint8_t> &data) {
for (int vert = 0; vert < size; vert++) { // Vertical counter
for (int j = 0; j < 2; j++) {
int x = right - j; // Actual x coordinate
bool upward = ((right & 2) == 0) ^ (x < 6);
bool upward = ((right + 1) & 2) == 0;
int y = upward ? size - 1 - vert : vert; // Actual y coordinate
if (!isFunction.at(y).at(x) && i < data.size() * 8) {
modules.at(y).at(x) = ((data.at(i >> 3) >> (7 - (i & 7))) & 1) != 0;

@ -504,7 +504,7 @@ public final class QrCode {
for (int vert = 0; vert < size; vert++) { // Vertical counter
for (int j = 0; j < 2; j++) {
int x = right - j; // Actual x coordinate
boolean upward = ((right & 2) == 0) ^ (x < 6);
boolean upward = ((right + 1) & 2) == 0;
int y = upward ? size - 1 - vert : vert; // Actual y coordinate
if (!isFunction[y][x] && i < data.length * 8) {
modules[y][x] = ((data[i >>> 3] >>> (7 - (i & 7))) & 1) != 0;

@ -405,7 +405,7 @@ var qrcodegen = new function() {
for (var vert = 0; vert < size; vert++) { // Vertical counter
for (var j = 0; j < 2; j++) {
var x = right - j; // Actual x coordinate
var upward = ((right & 2) == 0) ^ (x < 6);
var upward = ((right + 1) & 2) == 0;
var y = upward ? size - 1 - vert : vert; // Actual y coordinate
if (!isFunction[y][x] && i < data.length * 8) {
modules[y][x] = ((data[i >>> 3] >>> (7 - (i & 7))) & 1) != 0;

@ -404,7 +404,7 @@ class QrCode(object):
for vert in range(self._size): # Vertical counter
for j in range(2):
x = right - j # Actual x coordinate
upward = ((right & 2) == 0) ^ (x < 6)
upward = ((right + 1) & 2) == 0
y = (self._size - 1 - vert) if upward else vert # Actual y coordinate
if not self._isfunction[y][x] and i < len(data) * 8:
self._modules[y][x] = ((data[i >> 3] >> (7 - (i & 7))) & 1) != 0

Loading…
Cancel
Save