[librsvg: 6/15] Path: use a simple Rc<SvgPath>, not an Option around that
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 6/15] Path: use a simple Rc<SvgPath>, not an Option around that
- Date: Tue, 1 Dec 2020 22:17:53 +0000 (UTC)
commit cda9d80f48b833a0689e9d77eaf06c7390ca2949
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Dec 1 14:38:32 2020 -0600
Path: use a simple Rc<SvgPath>, not an Option around that
Now that SvgPath impls Default, we can avoid the intermediate option
during default construction.
src/shapes.rs | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/src/shapes.rs b/src/shapes.rs
index 9e7d5580..9948e206 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -116,7 +116,7 @@ fn make_ellipse(cx: f64, cy: f64, rx: f64, ry: f64) -> SvgPath {
#[derive(Default)]
pub struct Path {
- path: Option<Rc<SvgPath>>,
+ path: Rc<SvgPath>,
}
impl SetAttributes for Path {
@@ -130,7 +130,7 @@ impl SetAttributes for Path {
rsvg_log!("could not parse path: {}", e);
}
- self.path = Some(Rc::new(builder.into_path()));
+ self.path = Rc::new(builder.into_path());
}
}
@@ -140,10 +140,7 @@ impl SetAttributes for Path {
impl BasicShape for Path {
fn make_path(&self, _values: &ComputedValues, _draw_ctx: &mut DrawingCtx) -> Rc<SvgPath> {
- self.path
- .as_ref()
- .map(Rc::clone)
- .unwrap_or_else(|| Rc::new(PathBuilder::default().into_path()))
+ self.path.clone()
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]