diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2018-02-12 12:28:32 -0700 |
|---|---|---|
| committer | Mark Simulacrum <mark.simulacrum@gmail.com> | 2018-02-12 12:28:32 -0700 |
| commit | f237e9e2e74dfd5b223589f6254c80e8a69b724e (patch) | |
| tree | 6d5617a80560f7588ff21d4099f5c1717a7010db /src/libsyntax/codemap.rs | |
| parent | 16362c737fe740f630ada06349fa9004e2a51bb7 (diff) | |
| download | rust-f237e9e2e74dfd5b223589f6254c80e8a69b724e.tar.gz rust-f237e9e2e74dfd5b223589f6254c80e8a69b724e.zip | |
Remove allocation from width of character function.
Diffstat (limited to 'src/libsyntax/codemap.rs')
| -rw-r--r-- | src/libsyntax/codemap.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 3601b9ba8a8..ff6f32fc3be 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -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; }; |
