From 66806229ad8394e308ea1199401bdac01d92d994 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 7 Apr 2016 16:24:10 -0700 Subject: [PATCH] Prevent unnecessary copying in strip_leading_whitespace_if_necessary --- components/layout/fragment.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index bb761603f2f..50ecb69e025 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -2344,7 +2344,10 @@ impl Fragment { modified = true; continue } - new_text_string.push_str(&unscanned_text_fragment_info.text[i..]); + // Finished processing leading control chars and whitespace. + if modified { + new_text_string.push_str(&unscanned_text_fragment_info.text[i..]); + } break } if modified {