Simplified an analogous piece of C++ and Rust code.
This commit is contained in:
parent
eb200b8ebc
commit
5ddb2e9d63
|
@ -81,10 +81,9 @@ QrCode QrCode::encodeSegments(const vector<QrSegment> &segs, const Ecc &ecl,
|
|||
|
||||
// Increase the error correction level while the data still fits in the current version number
|
||||
const Ecc *newEcl = &ecl;
|
||||
if (boostEcl) {
|
||||
if (dataUsedBits <= getNumDataCodewords(version, Ecc::MEDIUM ) * 8) newEcl = &Ecc::MEDIUM ;
|
||||
if (dataUsedBits <= getNumDataCodewords(version, Ecc::QUARTILE) * 8) newEcl = &Ecc::QUARTILE;
|
||||
if (dataUsedBits <= getNumDataCodewords(version, Ecc::HIGH ) * 8) newEcl = &Ecc::HIGH ;
|
||||
for (const Ecc *anEcl : vector<const Ecc*>{&Ecc::MEDIUM, &Ecc::QUARTILE, &Ecc::HIGH}) {
|
||||
if (boostEcl && dataUsedBits <= getNumDataCodewords(version, *anEcl) * 8)
|
||||
newEcl = anEcl;
|
||||
}
|
||||
|
||||
// Create the data bit string by concatenating all segments
|
||||
|
|
|
@ -92,10 +92,10 @@ impl QrCode {
|
|||
}
|
||||
|
||||
// Increase the error correction level while the data still fits in the current version number
|
||||
if boostecl {
|
||||
if datausedbits <= QrCode::get_num_data_codewords(version, &QrCodeEcc_MEDIUM ) * 8 { ecl = &QrCodeEcc_MEDIUM ; }
|
||||
if datausedbits <= QrCode::get_num_data_codewords(version, &QrCodeEcc_QUARTILE) * 8 { ecl = &QrCodeEcc_QUARTILE; }
|
||||
if datausedbits <= QrCode::get_num_data_codewords(version, &QrCodeEcc_HIGH ) * 8 { ecl = &QrCodeEcc_HIGH ; }
|
||||
for newecl in &[&QrCodeEcc_MEDIUM, &QrCodeEcc_QUARTILE, &QrCodeEcc_HIGH] {
|
||||
if boostecl && datausedbits <= QrCode::get_num_data_codewords(version, newecl) * 8 {
|
||||
ecl = newecl;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the data bit string by concatenating all segments
|
||||
|
|
Loading…
Reference in New Issue