Skip to content

Commit 585bede

Browse files
committed
fix: name_index_mapping
1 parent 428b470 commit 585bede

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/replace_source.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ impl<'a, T: Source> StreamChunks<'a> for ReplaceSource<T> {
277277
RefCell::new(Vec::new());
278278
let name_mapping: RefCell<HashMap<Cow<str>, u32>> =
279279
RefCell::new(HashMap::default());
280-
let name_index_mapping: RefCell<Vec<u32>> = RefCell::new(Vec::new());
280+
let name_index_mapping: RefCell<HashMap<u32, u32>> =
281+
RefCell::new(HashMap::default());
281282

282283
// check if source_content[line][col] is equal to expect
283284
// Why this is needed?
@@ -413,7 +414,7 @@ impl<'a, T: Source> StreamChunks<'a> for ReplaceSource<T> {
413414
name_index: original.name_index.and_then(|name_index| {
414415
name_index_mapping
415416
.borrow()
416-
.get(name_index as usize)
417+
.get(&name_index)
417418
.copied()
418419
}),
419420
}
@@ -591,7 +592,7 @@ impl<'a, T: Source> StreamChunks<'a> for ReplaceSource<T> {
591592
name_index: original.name_index.and_then(|name_index| {
592593
name_index_mapping
593594
.borrow()
594-
.get(name_index as usize)
595+
.get(&name_index)
595596
.copied()
596597
}),
597598
}
@@ -621,7 +622,7 @@ impl<'a, T: Source> StreamChunks<'a> for ReplaceSource<T> {
621622
}
622623
name_index_mapping
623624
.borrow_mut()
624-
.insert(name_index as usize, global_index.unwrap());
625+
.insert(name_index, global_index.unwrap());
625626
},
626627
);
627628

0 commit comments

Comments
 (0)