diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index bb07404..717018b 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -90,8 +90,7 @@ QrCode QrCode::encodeSegments(const vector &segs, const Ecc &ecl, // Create the data bit string by concatenating all segments int dataCapacityBits = getNumDataCodewords(version, *newEcl) * 8; BitBuffer bb; - for (size_t i = 0; i < segs.size(); i++) { - const QrSegment &seg(segs.at(i)); + for (const QrSegment &seg : segs) { bb.appendBits(seg.mode.modeBits, 4); bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version)); bb.appendData(seg); @@ -596,8 +595,8 @@ QrCode::ReedSolomonGenerator::ReedSolomonGenerator(int degree) : vector QrCode::ReedSolomonGenerator::getRemainder(const vector &data) const { // Compute the remainder by performing polynomial division vector result(coefficients.size()); - for (size_t i = 0; i < data.size(); i++) { - uint8_t factor = data.at(i) ^ result.at(0); + for (uint8_t b : data) { + uint8_t factor = b ^ result.at(0); result.erase(result.begin()); result.push_back(0); for (size_t j = 0; j < result.size(); j++) diff --git a/cpp/QrSegment.cpp b/cpp/QrSegment.cpp index 1d31746..b05c7e8 100644 --- a/cpp/QrSegment.cpp +++ b/cpp/QrSegment.cpp @@ -156,8 +156,7 @@ int QrSegment::getTotalBits(const vector &segs, int version) { if (version < 1 || version > 40) throw "Version number out of range"; int result = 0; - for (std::size_t i = 0; i < segs.size(); i++) { - const QrSegment &seg(segs.at(i)); + for (const QrSegment &seg : segs) { int ccbits = seg.mode.numCharCountBits(version); // Fail if segment length value doesn't fit in the length field's bit-width if (seg.numChars >= (1L << ccbits) || seg.bitLength > INT16_MAX)