Skip to content

Commit 5b25477

Browse files
authored
Rollup merge of rust-lang#48167 - Mark-Simulacrum:remove-allocation-codemap, r=estebank
Remove allocation from width of character function. Locally this seems to eliminate the problem or at least resolve most of the issue. Fixes rust-lang#48153. r? @estebank
2 parents 1806b19 + f237e9e commit 5b25477

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libsyntax/codemap.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -690,14 +690,16 @@ impl CodeMap {
690690
return 1;
691691
}
692692

693+
let src = local_begin.fm.external_src.borrow();
694+
693695
// We need to extend the snippet to the end of the src rather than to end_index so when
694696
// searching forwards for boundaries we've got somewhere to search.
695697
let snippet = if let Some(ref src) = local_begin.fm.src {
696698
let len = src.len();
697-
(&src[start_index..len]).to_string()
698-
} else if let Some(src) = local_begin.fm.external_src.borrow().get_source() {
699+
(&src[start_index..len])
700+
} else if let Some(src) = src.get_source() {
699701
let len = src.len();
700-
(&src[start_index..len]).to_string()
702+
(&src[start_index..len])
701703
} else {
702704
return 1;
703705
};

0 commit comments

Comments
 (0)