Simplified a bit of TypeScript and Rust code using for-each looping.
This commit is contained in:
parent
7eac8beffe
commit
1424d9f332
|
@ -567,10 +567,10 @@ impl QrCode {
|
||||||
// Interleave (not concatenate) the bytes from every block into a single sequence
|
// Interleave (not concatenate) the bytes from every block into a single sequence
|
||||||
let mut result = Vec::<u8>::with_capacity(rawcodewords);
|
let mut result = Vec::<u8>::with_capacity(rawcodewords);
|
||||||
for i in 0 .. shortblocklen + 1 {
|
for i in 0 .. shortblocklen + 1 {
|
||||||
for j in 0 .. numblocks {
|
for (j, block) in blocks.iter().enumerate() {
|
||||||
// Skip the padding byte in short blocks
|
// Skip the padding byte in short blocks
|
||||||
if i != shortblocklen - blockecclen || j >= numshortblocks {
|
if i != shortblocklen - blockecclen || j >= numshortblocks {
|
||||||
result.push(blocks[j][i]);
|
result.push(block[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -435,11 +435,11 @@ namespace qrcodegen {
|
||||||
// Interleave (not concatenate) the bytes from every block into a single sequence
|
// Interleave (not concatenate) the bytes from every block into a single sequence
|
||||||
let result: Array<byte> = [];
|
let result: Array<byte> = [];
|
||||||
for (let i = 0; i < blocks[0].length; i++) {
|
for (let i = 0; i < blocks[0].length; i++) {
|
||||||
for (let j = 0; j < blocks.length; j++) {
|
blocks.forEach((block, j) => {
|
||||||
// Skip the padding byte in short blocks
|
// Skip the padding byte in short blocks
|
||||||
if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)
|
if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)
|
||||||
result.push(blocks[j][i]);
|
result.push(block[i]);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
if (result.length != rawCodewords)
|
if (result.length != rawCodewords)
|
||||||
throw "Assertion error";
|
throw "Assertion error";
|
||||||
|
|
Loading…
Reference in New Issue