Skip to content

Commit

Permalink
Rollup merge of #48167 - Mark-Simulacrum:remove-allocation-codemap, r…
Browse files Browse the repository at this point in the history
…=estebank

Remove allocation from width of character function.

Locally this seems to eliminate the problem or at least resolve most of the
issue.

Fixes #48153.

r? @estebank
  • Loading branch information
kennytm authored Feb 13, 2018
2 parents 1806b19 + f237e9e commit 5b25477
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libsyntax/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,14 +690,16 @@ impl CodeMap {
return 1;
}

let src = local_begin.fm.external_src.borrow();

// We need to extend the snippet to the end of the src rather than to end_index so when
// searching forwards for boundaries we've got somewhere to search.
let snippet = if let Some(ref src) = local_begin.fm.src {
let len = src.len();
(&src[start_index..len]).to_string()
} else if let Some(src) = local_begin.fm.external_src.borrow().get_source() {
(&src[start_index..len])
} else if let Some(src) = src.get_source() {
let len = src.len();
(&src[start_index..len]).to_string()
(&src[start_index..len])
} else {
return 1;
};
Expand Down

0 comments on commit 5b25477

Please sign in to comment.