Skip to content

Commit 0c6cca9

Browse files
authored
Use Arc for PaintWorklet arguments (#144)
This is a performance optimization from Gecko that I think we ought to adopt. See: https://bugzilla.mozilla.org/show_bug.cgi?id=1405411 No Servo changes required. Signed-off-by: Nico Burns <[email protected]>
1 parent 13b787c commit 0c6cca9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

style/values/generics/image.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::values::generics::Optional;
1313
use crate::values::serialize_atom_identifier;
1414
use crate::Atom;
1515
use crate::Zero;
16+
use servo_arc::Arc;
1617
use std::fmt::{self, Write};
1718
use style_traits::{CssWriter, ToCss};
1819

@@ -367,9 +368,10 @@ pub struct PaintWorklet {
367368
pub name: Atom,
368369
/// The arguments for the worklet.
369370
/// TODO: store a parsed representation of the arguments.
371+
#[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")]
370372
#[compute(no_field_bound)]
371373
#[resolve(no_field_bound)]
372-
pub arguments: Vec<custom_properties::SpecifiedValue>,
374+
pub arguments: Vec<Arc<custom_properties::SpecifiedValue>>,
373375
}
374376

375377
impl ::style_traits::SpecifiedValueInfo for PaintWorklet {}

style/values/specified/image.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1275,12 +1275,14 @@ impl<T> generic::ColorStop<Color, T> {
12751275
impl PaintWorklet {
12761276
#[cfg(feature = "servo")]
12771277
fn parse_args<'i>(context: &ParserContext, input: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>> {
1278+
use servo_arc::Arc;
1279+
12781280
use crate::custom_properties::SpecifiedValue;
12791281
let name = Atom::from(&**input.expect_ident()?);
12801282
let arguments = input
12811283
.try_parse(|input| {
12821284
input.expect_comma()?;
1283-
input.parse_comma_separated(|input| SpecifiedValue::parse(input, &context.url_data))
1285+
input.parse_comma_separated(|input| SpecifiedValue::parse(input, &context.url_data).map(Arc::new))
12841286
})
12851287
.unwrap_or_default();
12861288
Ok(Self { name, arguments })

0 commit comments

Comments
 (0)