Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] Remove allocation from width of character function. #48730

Merged
merged 1 commit into from
Mar 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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