Simplified some logic in Python and Rust code.

pull/31/head
Project Nayuki 7 years ago
parent a54cadf25a
commit 606a2d2924

@ -498,12 +498,9 @@ class QrCode(object):
step = (ver * 4 + numalign * 2 + 1) // (2 * numalign - 2) * 2
else: # C-C-C-Combo breaker!
step = 26
result = [6]
pos = ver * 4 + 10
for _ in range(numalign - 1):
result.insert(1, pos)
pos -= step
return result
start = ver * 4 + 10
result = [(start - i * step) for i in range(numalign - 1)] + [6]
return list(reversed(result))
@staticmethod

@ -628,12 +628,10 @@ impl QrCode {
} else { // C-C-C-Combo breaker!
26
};
let mut result = vec![6i32];
let mut pos: i32 = (ver as i32) * 4 + 10;
for _ in 0 .. numalign - 1 {
result.insert(1, pos);
pos -= step;
}
let start = (ver as i32) * 4 + 10;
let mut result: Vec<i32> = (0 .. numalign - 1).map(|i| start - i * step).collect();
result.push(6);
result.reverse();
result
}
}

Loading…
Cancel
Save