perf: QRCode: skip extra version check

ported from: ac88bce743

The version bits have already been parsed during detection. If they would
have been wrong then, we would not have ended up here. If we did, there is
no point in reading them again.
This commit is contained in:
Henry Schimke
2024-01-11 17:39:27 -06:00
parent 5e50394ba6
commit 415001f622

View File

@@ -29,38 +29,10 @@ pub fn ReadVersion(bitMatrix: &BitMatrix, qr_type: Type) -> Result<VersionRef> {
let number = Version::Number(bitMatrix); let number = Version::Number(bitMatrix);
match qr_type { match qr_type {
Type::Model1 => return Version::Model1(number), Type::Model1 => Version::Model1(number),
Type::Micro => Version::Micro(number),
Type::Micro => return Version::Micro(number), Type::Model2 => Version::Model2(number),
Type::Model2 => {}
} }
let mut version = Version::Model2(number)?;
if version.getVersionNumber() < 7 {
return Ok(version);
}
let dimension = bitMatrix.height();
for mirror in [false, true] {
// for (bool mirror : {false, true}) {
// Read top-right/bottom-left version info: 3 wide by 6 tall (depending on mirrored)
let mut versionBits = 0;
for y in (0..=5).rev() {
// for (int y = 5; y >= 0; --y) {
for x in ((dimension - 11)..=(dimension - 9)).rev() {
// for (int x = dimension - 9; x >= dimension - 11; --x) {
AppendBit(&mut versionBits, getBit(bitMatrix, x, y, Some(mirror)));
}
}
version = Version::DecodeVersionInformation(versionBits, 0)?; // THIS MIGHT BE WRONG todo!()
if version.getDimensionForVersion() == dimension {
return Ok(version);
}
}
Err(Exceptions::FORMAT)
} }
pub fn ReadFormatInformation(bitMatrix: &BitMatrix) -> Result<FormatInformation> { pub fn ReadFormatInformation(bitMatrix: &BitMatrix) -> Result<FormatInformation> {