feat: Replace compressed Match fields by uncompressed ones

This commit is contained in:
Clément Renault 2019-02-02 14:17:50 +01:00
parent b0b3175641
commit a3a28c56fa
No known key found for this signature in database
GPG key ID: 0151CDAB43460DAE
5 changed files with 56 additions and 42 deletions

View file

@ -70,12 +70,10 @@ fn create_highlight_areas(text: &str, matches: &[Match], attribute: SchemaAttr)
let mut byte_indexes = BTreeMap::new();
for match_ in matches {
let match_attribute = match_.attribute.attribute();
let match_attribute = match_.attribute;
if SchemaAttr::new(match_attribute) == attribute {
let word_area = match_.word_area;
let char_index = word_area.char_index() as usize;
let char_length = word_area.length() as usize;
let char_index = match_.char_index as usize;
let char_length = match_.char_length as usize;
let (byte_index, byte_length) = char_to_byte_range(char_index, char_length, text);
match byte_indexes.entry(byte_index) {
@ -151,7 +149,7 @@ fn main() -> Result<(), Box<Error>> {
let mut matching_attributes = HashSet::new();
for _match in doc.matches {
let attr = SchemaAttr::new(_match.attribute.attribute());
let attr = SchemaAttr::new(_match.attribute);
let name = schema.attribute_name(attr);
matching_attributes.insert(name);
}