Simplified some logic in Python and Rust code.

This commit is contained in:
Project Nayuki 2018-04-13 18:56:36 +00:00
parent a54cadf25a
commit 606a2d2924
2 changed files with 7 additions and 12 deletions

View File

@ -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

View File

@ -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
}
}