about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-02-14 16:14:47 +0800
committerkennytm <kennytm@gmail.com>2018-02-14 18:25:27 +0800
commitdc9d93f220c2adb3d89936fb2d82e1bebad0ddc7 (patch)
treee76cdea0724f85cc1ae17a1736ccaf068f69acbc /src/libsyntax
parent526e9548dc087926aabcfe50f76c393ade09d732 (diff)
parentf237e9e2e74dfd5b223589f6254c80e8a69b724e (diff)
downloadrust-dc9d93f220c2adb3d89936fb2d82e1bebad0ddc7.tar.gz
rust-dc9d93f220c2adb3d89936fb2d82e1bebad0ddc7.zip
Rollup merge of #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 #48153.

r? @estebank
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/codemap.rs8
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;
         };