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 step = (ver * 4 + numalign * 2 + 1) // (2 * numalign - 2) * 2
else: # C-C-C-Combo breaker! else: # C-C-C-Combo breaker!
step = 26 step = 26
result = [6] start = ver * 4 + 10
pos = ver * 4 + 10 result = [(start - i * step) for i in range(numalign - 1)] + [6]
for _ in range(numalign - 1): return list(reversed(result))
result.insert(1, pos)
pos -= step
return result
@staticmethod @staticmethod

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

Loading…
Cancel
Save