mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
update eci_string_builder
This change modifies how the ECIStringBuilder works. Perviously it encoded data as it went, whenever the eci state changed. The new method only decodes data when it is requested, simply appending bytes as it goes otherwise. This should improve performance in a few situations. This release also uses the ECIStringBuilder in qrcodes, which previously handled their own decoding.
This commit is contained in:
@@ -739,21 +739,21 @@ fn decodeBase256Segment(
|
||||
fn decodeECISegment(bits: &mut BitSource, result: &mut ECIStringBuilder) -> Result<bool> {
|
||||
let firstByte = bits.readBits(8)?;
|
||||
if firstByte <= 127 {
|
||||
result.appendECI(Eci::from(firstByte - 1))?;
|
||||
result.append_eci(Eci::from(firstByte - 1));
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
let secondByte = bits.readBits(8)?;
|
||||
if firstByte <= 191 {
|
||||
result.appendECI(Eci::from((firstByte - 128) * 254 + 127 + secondByte - 1))?;
|
||||
result.append_eci(Eci::from((firstByte - 128) * 254 + 127 + secondByte - 1));
|
||||
return Ok((firstByte - 128) * 254 + 127 + secondByte - 1 > 900);
|
||||
}
|
||||
|
||||
let thirdByte = bits.readBits(8)?;
|
||||
|
||||
result.appendECI(Eci::from(
|
||||
result.append_eci(Eci::from(
|
||||
(firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1,
|
||||
))?;
|
||||
));
|
||||
Ok((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1 > 900)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user