Skip to content

Commit d2c5f86

Browse files
committed
color: Avoid a string copy in parse_color_function.
1 parent 0ebd17b commit d2c5f86

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/color.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::f32::consts::PI;
99
use std::fmt;
1010
use std::str::FromStr;
1111

12-
use super::{ParseError, Parser, ToCss, Token};
12+
use super::{CowRcStr, ParseError, Parser, ToCss, Token};
1313

1414
#[cfg(feature = "serde")]
1515
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -902,7 +902,7 @@ where
902902
Token::Function(ref name) => {
903903
let name = name.clone();
904904
return input.parse_nested_block(|arguments| {
905-
parse_color_function(color_parser, &name, arguments)
905+
parse_color_function(color_parser, name, arguments)
906906
});
907907
}
908908
_ => Err(()),
@@ -1210,13 +1210,13 @@ where
12101210
#[inline]
12111211
fn parse_color_function<'i, 't, P>(
12121212
color_parser: &P,
1213-
name: &str,
1213+
name: CowRcStr<'i>,
12141214
arguments: &mut Parser<'i, 't>,
12151215
) -> Result<P::Output, ParseError<'i, P::Error>>
12161216
where
12171217
P: ColorParser<'i>,
12181218
{
1219-
let color = match_ignore_ascii_case! { name,
1219+
let color = match_ignore_ascii_case! { &name,
12201220
"rgb" | "rgba" => parse_rgb(color_parser, arguments),
12211221

12221222
"hsl" | "hsla" => parse_hsl(color_parser, arguments),
@@ -1241,7 +1241,7 @@ where
12411241

12421242
"color" => parse_color_with_color_space(color_parser, arguments),
12431243

1244-
_ => return Err(arguments.new_unexpected_token_error(Token::Ident(name.to_owned().into()))),
1244+
_ => return Err(arguments.new_unexpected_token_error(Token::Ident(name))),
12451245
}?;
12461246

12471247
arguments.expect_exhausted()?;

0 commit comments

Comments
 (0)