servo: Merge #17787 - Store COW strings in CSS parser errors when possible (from jdm:invalidvalue); r=SimonSapin
authorJosh Matthews <josh@joshmatthews.net>
Wed, 19 Jul 2017 10:08:14 -0700
changeset 418396 43d31b5d432513ccdb1482e82d6dff321377137e
parent 418395 9fc3f64f258358a93d2b6ea11e931725a8e3e677
child 418397 22e24b1ada9431c21c7f1f8a950d68ec94842c83
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSimonSapin
bugs17787
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17787 - Store COW strings in CSS parser errors when possible (from jdm:invalidvalue); r=SimonSapin This should be a straightforward performance improvement in pages with lots of CSS property values that the parser does not understand. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes do not require tests because there's no functional difference. Source-Repo: https://github.com/servo/servo Source-Revision: b70cbeb84caf5ec4a90a900fc5d4082989044acd
servo/components/style/properties/properties.mako.rs
servo/components/style_traits/lib.rs
servo/ports/geckolib/error_reporter.rs
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -1476,17 +1476,17 @@ impl PropertyDeclaration {
                       "Declarations are only expected inside a keyframe, page, or style rule.");
         id.check_allowed_in(rule_type, context.stylesheet_origin)?;
         match id {
             PropertyId::Custom(name) => {
                 let value = match input.try(|i| CSSWideKeyword::parse(context, i)) {
                     Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword),
                     Err(_) => match ::custom_properties::SpecifiedValue::parse(context, input) {
                         Ok(value) => DeclaredValueOwned::Value(value),
-                        Err(_) => return Err(PropertyDeclarationParseError::InvalidValue(name.to_string())),
+                        Err(_) => return Err(PropertyDeclarationParseError::InvalidValue(name.to_string().into())),
                     }
                 };
                 declarations.push(PropertyDeclaration::Custom(name, value));
                 Ok(())
             }
             PropertyId::Longhand(id) => {
                 input.try(|i| CSSWideKeyword::parse(context, i)).map(|keyword| {
                     PropertyDeclaration::CSSWideKeyword(id, keyword)
--- a/servo/components/style_traits/lib.rs
+++ b/servo/components/style_traits/lib.rs
@@ -119,17 +119,17 @@ pub enum StyleParseError<'i> {
 pub enum PropertyDeclarationParseError<'i> {
     /// The property declaration was for an unknown property.
     UnknownProperty(CompactCowStr<'i>),
     /// An unknown vendor-specific identifier was encountered.
     UnknownVendorProperty,
     /// The property declaration was for a disabled experimental property.
     ExperimentalProperty,
     /// The property declaration contained an invalid value.
-    InvalidValue(String),
+    InvalidValue(CompactCowStr<'i>),
     /// The declaration contained an animation property, and we were parsing
     /// this as a keyframe block (so that property should be ignored).
     ///
     /// See: https://drafts.csswg.org/css-animations/#keyframes
     AnimationPropertyInKeyframeBlock,
     /// The property is not allowed within a page rule.
     NotAllowedInPageRule,
 }
--- a/servo/ports/geckolib/error_reporter.rs
+++ b/servo/ports/geckolib/error_reporter.rs
@@ -219,17 +219,17 @@ impl<'a> ErrorHelpers<'a> for Contextual
                 ErrorString::UnexpectedToken(t),
 
             (_, CssParseError::Basic(BasicParseError::AtRuleInvalid(i))) =>
                 ErrorString::Snippet(format!("@{}", escape_css_ident(&i)).into()),
 
             (_, CssParseError::Custom(SelectorParseError::Custom(
                 StyleParseError::PropertyDeclaration(
                     PropertyDeclarationParseError::InvalidValue(property))))) =>
-                ErrorString::Snippet(property.into()),
+                ErrorString::Snippet(property),
 
             (_, CssParseError::Custom(SelectorParseError::UnexpectedIdent(ident))) =>
                 ErrorString::Ident(ident),
 
             (_, CssParseError::Custom(SelectorParseError::ExpectedNamespace(namespace))) =>
                 ErrorString::Ident(namespace),
 
             (_, CssParseError::Custom(SelectorParseError::Custom(