From 752eb9d0999bc50cd26d2c7ce51214b9f87b3e09 Mon Sep 17 00:00:00 2001 From: Rasmus Kaj Date: Sun, 2 Sep 2018 20:10:42 +0200 Subject: [PATCH] Avoid som allocation Use &str in some places where allocating a String is not necessary. --- src/parser/strings.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/parser/strings.rs b/src/parser/strings.rs index f7d391daf..c49fa5430 100644 --- a/src/parser/strings.rs +++ b/src/parser/strings.rs @@ -1,6 +1,6 @@ -use super::input_to_string; use super::util::is_name_char; use super::value::value_expression; +use super::{input_to_str, input_to_string}; use nom::alphanumeric; use nom::types::CompleteByteSlice as Input; use sass::{SassString, StringPart}; @@ -73,25 +73,25 @@ named!( | hash_no_interpolation ), String::new(), - |mut acc: String, item: String| { - acc.push_str(&item); + |mut acc: String, item: &str| { + acc.push_str(item); acc } ) ); named!( - selector_plain_part, - map_res!(is_not!("\n\t >$\"'\\#+*/()[]{}:;,=!&@"), input_to_string) + selector_plain_part, + map_res!(is_not!("\n\t >$\"'\\#+*/()[]{}:;,=!&@"), input_to_str) ); named!( - selector_escaped_part, + selector_escaped_part, map_res!( recognize!(preceded!( tag!("\\"), alt!(value!((), many_m_n!(1, 3, hexpair)) | value!((), take!(1))) )), - input_to_string + input_to_str ) ); named!( @@ -103,8 +103,8 @@ named!( )) ); named!( - hash_no_interpolation, - map_res!(terminated!(tag!("#"), peek!(not!(tag!("{")))), input_to_string) + hash_no_interpolation, + map_res!(terminated!(tag!("#"), peek!(not!(tag!("{")))), input_to_str) ); named!( extra_escape,