mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #20038 - emilio:no-need-for-strings, r=nox
style: Avoid an intermediate buffer in Servo_Shorthand_AnimationValues_Serialize. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20038) <!-- Reviewable:end -->
This commit is contained in:
commit
4c3f1756da
1 changed files with 10 additions and 11 deletions
|
@ -709,10 +709,11 @@ pub extern "C" fn Servo_AnimationValue_Serialize(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Shorthand_AnimationValues_Serialize(shorthand_property: nsCSSPropertyID,
|
||||
values: RawGeckoServoAnimationValueListBorrowed,
|
||||
buffer: *mut nsAString)
|
||||
{
|
||||
pub unsafe extern "C" fn Servo_Shorthand_AnimationValues_Serialize(
|
||||
shorthand_property: nsCSSPropertyID,
|
||||
values: RawGeckoServoAnimationValueListBorrowed,
|
||||
buffer: *mut nsAString,
|
||||
) {
|
||||
let property_id = get_property_id_from_nscsspropertyid!(shorthand_property, ());
|
||||
let shorthand = match property_id.as_shorthand() {
|
||||
Ok(shorthand) => shorthand,
|
||||
|
@ -724,14 +725,12 @@ pub extern "C" fn Servo_Shorthand_AnimationValues_Serialize(shorthand_property:
|
|||
// about its lifetime. (longhands_to_css() expects &PropertyDeclaration
|
||||
// iterator.)
|
||||
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 rv = shorthand.longhands_to_css(declarations.iter(), &mut CssWriter::new(&mut string));
|
||||
if rv.is_ok() {
|
||||
let buffer = unsafe { buffer.as_mut().unwrap() };
|
||||
buffer.assign_utf8(&string);
|
||||
}
|
||||
let _ = shorthand.longhands_to_css(
|
||||
declarations.iter(),
|
||||
&mut CssWriter::new(&mut *buffer),
|
||||
);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue