Remove some useless clone() call on SpecifiedUrl::image_value. r?emilio
draft
Remove some useless clone() call on SpecifiedUrl::image_value. r?emilio
MozReview-Commit-ID: AGC6s15IoKD
--- a/servo/components/style/gecko/conversions.rs
+++ b/servo/components/style/gecko/conversions.rs
@@ -150,22 +150,22 @@ impl nsStyleImage {
/// Set a given Servo `Image` value into this `nsStyleImage`.
pub fn set(&mut self, image: Image) {
match image {
GenericImage::Gradient(boxed_gradient) => {
self.set_gradient(*boxed_gradient)
},
GenericImage::Url(ref url) => {
unsafe {
- Gecko_SetLayerImageImageValue(self, url.image_value.clone().unwrap().get());
+ Gecko_SetLayerImageImageValue(self, url.image_value.as_ref().unwrap().get());
}
},
GenericImage::Rect(ref image_rect) => {
unsafe {
- Gecko_SetLayerImageImageValue(self, image_rect.url.image_value.clone().unwrap().get());
+ Gecko_SetLayerImageImageValue(self, image_rect.url.image_value.as_ref().unwrap().get());
Gecko_InitializeImageCropRect(self);
// Set CropRect
let ref mut rect = *self.mCropRect.mPtr;
image_rect.top.to_gecko_style_coord(&mut rect.data_at_mut(0));
image_rect.right.to_gecko_style_coord(&mut rect.data_at_mut(1));
image_rect.bottom.to_gecko_style_coord(&mut rect.data_at_mut(2));
image_rect.left.to_gecko_style_coord(&mut rect.data_at_mut(3));
--- a/servo/components/style/gecko/url.rs
+++ b/servo/components/style/gecko/url.rs
@@ -145,14 +145,14 @@ impl MallocSizeOf for SpecifiedUrl {
// We ignore `extra_data`, because RefPtr is tricky, and there aren't
// many of them in practise (sharing is common).
if let Some(ref image_value) = self.image_value {
// Although this is a RefPtr, this is the primary reference because
// SpecifiedUrl is responsible for creating the image_value. So we
// measure unconditionally here.
- n += unsafe { Gecko_ImageValue_SizeOfIncludingThis(image_value.clone().get()) };
+ n += unsafe { Gecko_ImageValue_SizeOfIncludingThis(image_value.get()) };
}
n
}
}
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -4068,17 +4068,17 @@ fn static_assert() {
longhands::list_style_image::computed_value::T(Either::Second(_none)) => {
unsafe {
Gecko_SetListStyleImageNone(&mut self.gecko);
}
}
longhands::list_style_image::computed_value::T(Either::First(ref url)) => {
unsafe {
Gecko_SetListStyleImageImageValue(&mut self.gecko,
- url.image_value.clone().unwrap().get());
+ url.image_value.as_ref().unwrap().get());
}
// We don't need to record this struct as uncacheable, like when setting
// background-image to a url() value, since only properties in reset structs
// are re-used from the applicable declaration cache, and the List struct
// is an inherited struct.
}
}
}
@@ -5286,17 +5286,17 @@ clip-path
} as u8;
unsafe {
Gecko_SetCursorArrayLength(&mut self.gecko, v.images.len());
}
for i in 0..v.images.len() {
unsafe {
Gecko_SetCursorImageValue(&mut self.gecko.mCursorImages[i],
- v.images[i].url.clone().image_value.unwrap().get());
+ v.images[i].url.image_value.as_ref().unwrap().get());
}
// We don't need to record this struct as uncacheable, like when setting
// background-image to a url() value, since only properties in reset structs
// are re-used from the applicable declaration cache, and the Pointing struct
// is an inherited struct.
match v.images[i].hotspot {
@@ -5546,17 +5546,17 @@ clip-path
&sep,
style.clone(),
device,
);
}
ContentItem::Url(ref url) => {
unsafe {
bindings::Gecko_SetContentDataImageValue(&mut self.gecko.mContents[i],
- url.image_value.clone().unwrap().get())
+ url.image_value.as_ref().unwrap().get())
}
}
}
}
}
}
}