Skip to content

Commit 21143aa

Browse files
committed
syntax: Replace Vec::map_in_place with stable mut iterator
1 parent a2cfe38 commit 21143aa

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/libsyntax/codemap.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ impl CodeMap {
594594
pub fn new_imported_filemap(&self,
595595
filename: FileName,
596596
source_len: usize,
597-
file_local_lines: Vec<BytePos>,
598-
file_local_multibyte_chars: Vec<MultiByteChar>)
597+
mut file_local_lines: Vec<BytePos>,
598+
mut file_local_multibyte_chars: Vec<MultiByteChar>)
599599
-> Rc<FileMap> {
600600
let mut files = self.files.borrow_mut();
601601
let start_pos = match files.last() {
@@ -606,19 +606,21 @@ impl CodeMap {
606606
let end_pos = Pos::from_usize(start_pos + source_len);
607607
let start_pos = Pos::from_usize(start_pos);
608608

609-
let lines = file_local_lines.map_in_place(|pos| pos + start_pos);
610-
let multibyte_chars = file_local_multibyte_chars.map_in_place(|mbc| MultiByteChar {
611-
pos: mbc.pos + start_pos,
612-
bytes: mbc.bytes
613-
});
609+
for pos in &mut file_local_lines {
610+
*pos = *pos + start_pos;
611+
}
612+
613+
for mbc in &mut file_local_multibyte_chars {
614+
mbc.pos = mbc.pos + start_pos;
615+
}
614616

615617
let filemap = Rc::new(FileMap {
616618
name: filename,
617619
src: None,
618620
start_pos: start_pos,
619621
end_pos: end_pos,
620-
lines: RefCell::new(lines),
621-
multibyte_chars: RefCell::new(multibyte_chars),
622+
lines: RefCell::new(file_local_lines),
623+
multibyte_chars: RefCell::new(file_local_multibyte_chars),
622624
});
623625

624626
files.push(filemap.clone());

0 commit comments

Comments
 (0)