mirror of
https://github.com/servo/servo.git
synced 2025-07-14 02:43:42 +01:00
style: Avoid an intermediate buffer in Servo_Shorthand_AnimationValues_Serialize.
This commit is contained in:
parent
9e64008e75
commit
a02431d2ef
1 changed files with 10 additions and 11 deletions
|
@ -702,10 +702,11 @@ pub extern "C" fn Servo_AnimationValue_Serialize(value: RawServoAnimationValueBo
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_Shorthand_AnimationValues_Serialize(shorthand_property: nsCSSPropertyID,
|
pub unsafe extern "C" fn Servo_Shorthand_AnimationValues_Serialize(
|
||||||
|
shorthand_property: nsCSSPropertyID,
|
||||||
values: RawGeckoServoAnimationValueListBorrowed,
|
values: RawGeckoServoAnimationValueListBorrowed,
|
||||||
buffer: *mut nsAString)
|
buffer: *mut nsAString,
|
||||||
{
|
) {
|
||||||
let property_id = get_property_id_from_nscsspropertyid!(shorthand_property, ());
|
let property_id = get_property_id_from_nscsspropertyid!(shorthand_property, ());
|
||||||
let shorthand = match property_id.as_shorthand() {
|
let shorthand = match property_id.as_shorthand() {
|
||||||
Ok(shorthand) => shorthand,
|
Ok(shorthand) => shorthand,
|
||||||
|
@ -717,14 +718,12 @@ pub extern "C" fn Servo_Shorthand_AnimationValues_Serialize(shorthand_property:
|
||||||
// about its lifetime. (longhands_to_css() expects &PropertyDeclaration
|
// about its lifetime. (longhands_to_css() expects &PropertyDeclaration
|
||||||
// iterator.)
|
// iterator.)
|
||||||
let declarations: Vec<PropertyDeclaration> =
|
let declarations: Vec<PropertyDeclaration> =
|
||||||
values.iter().map(|v| AnimationValue::as_arc(unsafe { &&*v.mRawPtr }).uncompute()).collect();
|
values.iter().map(|v| AnimationValue::as_arc(&&*v.mRawPtr).uncompute()).collect();
|
||||||
|
|
||||||
let mut string = String::new();
|
let _ = shorthand.longhands_to_css(
|
||||||
let rv = shorthand.longhands_to_css(declarations.iter(), &mut CssWriter::new(&mut string));
|
declarations.iter(),
|
||||||
if rv.is_ok() {
|
&mut CssWriter::new(&mut *buffer),
|
||||||
let buffer = unsafe { buffer.as_mut().unwrap() };
|
);
|
||||||
buffer.assign_utf8(&string);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue