1
Fork 0

syntax_pos: Store multibyte char size as u8 instead of u32.

This commit is contained in:
Michael Woerister 2018-06-26 15:37:09 +02:00
parent ba1d18fe29
commit ba30c1dac9
3 changed files with 4 additions and 4 deletions

View file

@ -819,10 +819,10 @@ impl CodeMap {
if mbc.pos < bpos {
// every character is at least one byte, so we only
// count the actual extra bytes.
total_extra_bytes += mbc.bytes - 1;
total_extra_bytes += mbc.bytes as u32 - 1;
// We should never see a byte position in the middle of a
// character
assert!(bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes);
assert!(bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32);
} else {
break;
}

View file

@ -263,7 +263,7 @@ fn analyze_filemap_generic(src: &str,
assert!(char_len >=2 && char_len <= 4);
let mbc = MultiByteChar {
pos,
bytes: char_len as u32,
bytes: char_len as u8,
};
multi_byte_chars.push(mbc);
}

View file

@ -663,7 +663,7 @@ pub struct MultiByteChar {
/// The absolute offset of the character in the CodeMap
pub pos: BytePos,
/// The number of bytes, >=2
pub bytes: u32,
pub bytes: u8,
}
/// Identifies an offset of a non-narrow character in a FileMap