[librsvg: 1/2] Fix clippy borrow errors
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/2] Fix clippy borrow errors
- Date: Wed, 25 Aug 2021 01:32:03 +0000 (UTC)
commit d938f185ae25d4e0b0c8fc0c2d43ea83752c00e0
Author: Madds H <madds hollandart io>
Date: Mon Aug 23 09:51:49 2021 -0500
Fix clippy borrow errors
Most are references that are borrowed then immediately dereferenced
There's also a couple of unwraps that had function calls inside them
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/580>
src/accept_language.rs | 4 ++--
src/bin/rsvg-convert.rs | 12 ++++++------
src/c_api/handle.rs | 2 +-
src/css.rs | 2 +-
src/document.rs | 6 +++---
src/drawing_ctx.rs | 10 +++++-----
src/filter_func.rs | 20 ++++++++++----------
src/filters/image.rs | 6 +++---
src/filters/mod.rs | 4 ++--
src/filters/morphology.rs | 9 +++------
src/handle.rs | 6 +++---
src/layout.rs | 4 ++--
src/marker.rs | 8 ++++----
src/paint_server.rs | 6 +++---
src/path_builder.rs | 2 +-
src/pattern.rs | 4 ++--
src/shapes.rs | 4 ++--
src/structure.rs | 2 +-
src/surface_utils/shared_surface.rs | 2 +-
src/text.rs | 17 ++++++-----------
src/xml/mod.rs | 6 +++---
21 files changed, 64 insertions(+), 72 deletions(-)
---
diff --git a/src/accept_language.rs b/src/accept_language.rs
index c4190651..2b352db5 100644
--- a/src/accept_language.rs
+++ b/src/accept_language.rs
@@ -132,7 +132,7 @@ impl Item {
if qvalue.starts_with(&['0', '1'][..]) {
let first_digit = qvalue.chars().next().unwrap();
- if let Some(decimals) = qvalue[1..].strip_prefix(".") {
+ if let Some(decimals) = qvalue[1..].strip_prefix('.') {
if (first_digit == '0'
&& decimals.len() <= 3
&& decimals.chars().all(|c| c.is_digit(10)))
@@ -261,7 +261,7 @@ fn locale_from_environment() -> Locale {
for name in glib::language_names() {
let name = name.as_str();
- if let Ok(range) = LanguageRange::from_unix(&name) {
+ if let Ok(range) = LanguageRange::from_unix(name) {
locale.add(&range);
}
}
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index 589f583f..b5ebd81a 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -184,13 +184,13 @@ impl Deref for Surface {
fn deref(&self) -> &cairo::Surface {
match self {
- Self::Png(surface, _) => &surface,
+ Self::Png(surface, _) => surface,
#[cfg(system_deps_have_cairo_pdf)]
- Self::Pdf(surface, _) => &surface,
+ Self::Pdf(surface, _) => surface,
#[cfg(system_deps_have_cairo_ps)]
- Self::Ps(surface, _) => &surface,
+ Self::Ps(surface, _) => surface,
#[cfg(system_deps_have_cairo_svg)]
- Self::Svg(surface, _) => &surface,
+ Self::Svg(surface, _) => surface,
}
}
}
@@ -471,7 +471,7 @@ impl Converter {
if let Some(ref css) = stylesheet {
handle
- .set_stylesheet(&css)
+ .set_stylesheet(css)
.map_err(|e| error!("Error applying stylesheet: {}", e))?;
}
@@ -615,7 +615,7 @@ fn natural_geometry(
) -> Result<cairo::Rectangle, Error> {
match export_id {
None => renderer.legacy_layer_geometry(None),
- Some(ref id) => renderer.geometry_for_element(Some(&id)),
+ Some(id) => renderer.geometry_for_element(Some(id)),
}
.map(|(ink_r, _)| ink_r)
.map_err(|e| match e {
diff --git a/src/c_api/handle.rs b/src/c_api/handle.rs
index 269a97de..766091c9 100644
--- a/src/c_api/handle.rs
+++ b/src/c_api/handle.rs
@@ -631,7 +631,7 @@ impl CHandle {
}
}
- match Url::parse(&url) {
+ match Url::parse(url) {
Ok(u) => {
rsvg_log!("setting base_uri to \"{}\"", u.as_str());
let mut inner = imp.inner.borrow_mut();
diff --git a/src/css.rs b/src/css.rs
index 4331087a..bcffd335 100644
--- a/src/css.rs
+++ b/src/css.rs
@@ -679,7 +679,7 @@ impl Stylesheet {
.for_each(|rule| match rule {
Rule::AtRule(AtRule::Import(url)) => {
// ignore invalid imports
- let _ = self.load(&url, &url_resolver);
+ let _ = self.load(&url, url_resolver);
}
Rule::QualifiedRule(qr) => self.qualified_rules.push(qr),
});
diff --git a/src/document.rs b/src/document.rs
index 97dfbae7..406a6d79 100644
--- a/src/document.rs
+++ b/src/document.rs
@@ -251,7 +251,7 @@ fn load_image(
let BinaryData {
data: bytes,
mime_type,
- } = io::acquire_data(&aurl, None)?;
+ } = io::acquire_data(aurl, None)?;
if bytes.is_empty() {
return Err(LoadingError::Other(String::from("no image data")));
@@ -403,10 +403,10 @@ impl<'i> AcquiredNodes<'i> {
}
pub fn acquire_ref(&self, node: &Node) -> Result<AcquiredNode, AcquireError> {
- if self.node_stack.borrow().contains(&node) {
+ if self.node_stack.borrow().contains(node) {
Err(AcquireError::CircularReference(node.clone()))
} else {
- self.node_stack.borrow_mut().push(&node);
+ self.node_stack.borrow_mut().push(node);
Ok(AcquiredNode {
stack: Some(self.node_stack.clone()),
node: node.clone(),
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index b72060f9..57edfbbb 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -942,7 +942,7 @@ impl DrawingCtx {
{
specs.iter().try_fold(surface_to_filter, |surface, spec| {
filters::render(
- &spec,
+ spec,
stroke_paint_source.clone(),
fill_paint_source.clone(),
surface,
@@ -1400,7 +1400,7 @@ impl DrawingCtx {
}
let fill_paint =
- span.fill_paint.to_user_space(&bbox, &view_params, values);
+ span.fill_paint.to_user_space(&bbox, view_params, values);
let had_paint_server =
self.set_paint_source(&fill_paint, acquired_nodes)?;
if had_paint_server {
@@ -1420,7 +1420,7 @@ impl DrawingCtx {
}
let stroke_paint =
- span.stroke_paint.to_user_space(&bbox, &view_params, values);
+ span.stroke_paint.to_user_space(&bbox, view_params, values);
let had_paint_server =
self.set_paint_source(&stroke_paint, acquired_nodes)?;
if had_paint_server {
@@ -1659,7 +1659,7 @@ impl DrawingCtx {
child.draw_children(
an,
&CascadedValues::new_from_values(
- &child,
+ child,
values,
Some(fill_paint.clone()),
Some(stroke_paint.clone()),
@@ -1689,7 +1689,7 @@ impl DrawingCtx {
child.draw(
an,
&CascadedValues::new_from_values(
- &child,
+ child,
values,
Some(fill_paint.clone()),
Some(stroke_paint.clone()),
diff --git a/src/filter_func.rs b/src/filter_func.rs
index 48746fd8..ece4e9f2 100644
--- a/src/filter_func.rs
+++ b/src/filter_func.rs
@@ -642,16 +642,16 @@ impl FilterFunction {
current_color: RGBA,
) -> Result<FilterSpec, FilterResolveError> {
match self {
- FilterFunction::Blur(v) => Ok(v.to_filter_spec(¶ms)),
- FilterFunction::Brightness(v) => Ok(v.to_filter_spec(¶ms)),
- FilterFunction::Contrast(v) => Ok(v.to_filter_spec(¶ms)),
- FilterFunction::DropShadow(v) => Ok(v.to_filter_spec(¶ms, current_color)),
- FilterFunction::Grayscale(v) => Ok(v.to_filter_spec(¶ms)),
- FilterFunction::HueRotate(v) => Ok(v.to_filter_spec(¶ms)),
- FilterFunction::Invert(v) => Ok(v.to_filter_spec(¶ms)),
- FilterFunction::Opacity(v) => Ok(v.to_filter_spec(¶ms)),
- FilterFunction::Saturate(v) => Ok(v.to_filter_spec(¶ms)),
- FilterFunction::Sepia(v) => Ok(v.to_filter_spec(¶ms)),
+ FilterFunction::Blur(v) => Ok(v.to_filter_spec(params)),
+ FilterFunction::Brightness(v) => Ok(v.to_filter_spec(params)),
+ FilterFunction::Contrast(v) => Ok(v.to_filter_spec(params)),
+ FilterFunction::DropShadow(v) => Ok(v.to_filter_spec(params, current_color)),
+ FilterFunction::Grayscale(v) => Ok(v.to_filter_spec(params)),
+ FilterFunction::HueRotate(v) => Ok(v.to_filter_spec(params)),
+ FilterFunction::Invert(v) => Ok(v.to_filter_spec(params)),
+ FilterFunction::Opacity(v) => Ok(v.to_filter_spec(params)),
+ FilterFunction::Saturate(v) => Ok(v.to_filter_spec(params)),
+ FilterFunction::Sepia(v) => Ok(v.to_filter_spec(params)),
}
}
}
diff --git a/src/filters/image.rs b/src/filters/image.rs
index f5246403..243bf0cf 100644
--- a/src/filters/image.rs
+++ b/src/filters/image.rs
@@ -68,10 +68,10 @@ impl Image {
// I think this means that we use the same cascading mode as <use>, i.e. the
// referenced object inherits its properties from the feImage element.
let cascaded =
- CascadedValues::new_from_values(&referenced_node, &self.feimage_values, None, None);
+ CascadedValues::new_from_values(referenced_node, &self.feimage_values, None, None);
let image = draw_ctx.draw_node_to_surface(
- &referenced_node,
+ referenced_node,
acquired_nodes,
&cascaded,
ctx.paffine(),
@@ -157,7 +157,7 @@ impl Image {
acquired_nodes,
draw_ctx,
bounds.clipped,
- &acquired.get(),
+ acquired.get(),
)?
} else {
return Err(FilterError::InvalidInput);
diff --git a/src/filters/mod.rs b/src/filters/mod.rs
index e79eabbd..0b3136cd 100644
--- a/src/filters/mod.rs
+++ b/src/filters/mod.rs
@@ -285,7 +285,7 @@ pub fn extract_filter_from_filter_node(
let primitive_values = elt.get_computed_values();
let params = NormalizeParams::new(
- &primitive_values,
+ primitive_values,
&draw_ctx.get_view_params_for_units(user_space_filter.primitive_units),
);
@@ -332,7 +332,7 @@ pub fn render(
for user_space_primitive in &filter.primitives {
let start = Instant::now();
- match render_primitive(&user_space_primitive, &filter_ctx, acquired_nodes, draw_ctx) {
+ match render_primitive(user_space_primitive, &filter_ctx, acquired_nodes, draw_ctx) {
Ok(output) => {
let elapsed = start.elapsed();
rsvg_log!(
diff --git a/src/filters/morphology.rs b/src/filters/morphology.rs
index f1a3791a..7b4dbf37 100644
--- a/src/filters/morphology.rs
+++ b/src/filters/morphology.rs
@@ -132,12 +132,9 @@ impl Morphology {
a: initial,
};
- for (_x, _y, pixel) in PixelRectangle::within(
- &input_1.surface(),
- bounds,
- kernel_bounds,
- EdgeMode::None,
- ) {
+ for (_x, _y, pixel) in
+ PixelRectangle::within(input_1.surface(), bounds, kernel_bounds, EdgeMode::None)
+ {
let op = match self.operator {
Operator::Erode => min,
Operator::Dilate => max,
diff --git a/src/handle.rs b/src/handle.rs
index 7cfb23da..2bd121da 100644
--- a/src/handle.rs
+++ b/src/handle.rs
@@ -136,7 +136,7 @@ impl Handle {
let cascaded = CascadedValues::new_from_node(&root);
let values = cascaded.get();
- let params = NormalizeParams::new(&values, &view_params);
+ let params = NormalizeParams::new(values, &view_params);
Some((w.to_user(¶ms), h.to_user(¶ms)))
}
@@ -200,7 +200,7 @@ impl Handle {
}
fn lookup_node(&self, id: &str) -> Result<Node, DefsLookupErrorKind> {
- let node_id = NodeId::parse(&id).map_err(|_| DefsLookupErrorKind::InvalidId)?;
+ let node_id = NodeId::parse(id).map_err(|_| DefsLookupErrorKind::InvalidId)?;
// The public APIs to get geometries of individual elements, or to render
// them, should only allow referencing elements within the main handle's
@@ -354,7 +354,7 @@ impl Handle {
draw_tree(
DrawingMode::OnlyNode(node),
- &cr,
+ cr,
unit_rectangle(),
user_language,
dpi,
diff --git a/src/layout.rs b/src/layout.rs
index 189f0e00..91fd8cb5 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -216,13 +216,13 @@ impl Stroke {
let miter_limit = values.stroke_miterlimit();
let line_cap = values.stroke_line_cap();
let line_join = values.stroke_line_join();
- let dash_offset = values.stroke_dashoffset().0.to_user(¶ms);
+ let dash_offset = values.stroke_dashoffset().0.to_user(params);
let dashes = match values.stroke_dasharray() {
StrokeDasharray(Dasharray::None) => Box::new([]),
StrokeDasharray(Dasharray::Array(dashes)) => dashes
.iter()
- .map(|l| l.to_user(¶ms))
+ .map(|l| l.to_user(params))
.collect::<Box<[f64]>>(),
};
diff --git a/src/marker.rs b/src/marker.rs
index a27dad80..c0c37a6b 100644
--- a/src/marker.rs
+++ b/src/marker.rs
@@ -114,14 +114,14 @@ impl Marker {
marker_type: MarkerType,
marker: &layout::Marker,
) -> Result<BoundingBox, RenderingError> {
- let mut cascaded = CascadedValues::new_from_node(&node);
+ let mut cascaded = CascadedValues::new_from_node(node);
cascaded.context_fill = Some(marker.context_fill.clone());
cascaded.context_stroke = Some(marker.context_stroke.clone());
let values = cascaded.get();
let view_params = draw_ctx.get_view_params();
- let params = NormalizeParams::new(&values, &view_params);
+ let params = NormalizeParams::new(values, &view_params);
let marker_width = self.width.to_user(¶ms);
let marker_height = self.height.to_user(¶ms);
@@ -167,7 +167,7 @@ impl Marker {
draw_ctx.push_view_box(marker_width, marker_height)
};
- let content_params = NormalizeParams::new(&values, &content_view_params);
+ let content_params = NormalizeParams::new(values, &content_view_params);
transform = transform.pre_translate(
-self.ref_x.to_user(&content_params),
@@ -588,7 +588,7 @@ fn emit_marker_by_node(
let marker_elt = borrow_element_as!(node, Marker);
marker_elt.render(
- &node,
+ node,
acquired_nodes,
draw_ctx,
xpos,
diff --git a/src/paint_server.rs b/src/paint_server.rs
index 70ee8b6f..2626d60d 100644
--- a/src/paint_server.rs
+++ b/src/paint_server.rs
@@ -139,7 +139,7 @@ impl PaintServer {
match *node.borrow_element() {
Element::LinearGradient(ref g) => {
- g.resolve(&node, acquired_nodes, opacity).map(|g| {
+ g.resolve(node, acquired_nodes, opacity).map(|g| {
PaintSource::Gradient(
g,
alternate.map(|c| resolve_color(&c, opacity, current_color)),
@@ -147,7 +147,7 @@ impl PaintServer {
})
}
Element::Pattern(ref p) => {
- p.resolve(&node, acquired_nodes, opacity).map(|p| {
+ p.resolve(node, acquired_nodes, opacity).map(|p| {
PaintSource::Pattern(
p,
alternate.map(|c| resolve_color(&c, opacity, current_color)),
@@ -155,7 +155,7 @@ impl PaintServer {
})
}
Element::RadialGradient(ref g) => {
- g.resolve(&node, acquired_nodes, opacity).map(|g| {
+ g.resolve(node, acquired_nodes, opacity).map(|g| {
PaintSource::Gradient(
g,
alternate.map(|c| resolve_color(&c, opacity, current_color)),
diff --git a/src/path_builder.rs b/src/path_builder.rs
index 95b1399b..eb9449b8 100644
--- a/src/path_builder.rs
+++ b/src/path_builder.rs
@@ -704,7 +704,7 @@ impl Path {
/// Get an iterator over a path `Subpath`s.
pub fn iter_subpath(&self) -> SubPathIter<'_> {
SubPathIter {
- path: &self,
+ path: self,
commands_start: 0,
coords_start: 0,
}
diff --git a/src/pattern.rs b/src/pattern.rs
index 42f87941..3262f297 100644
--- a/src/pattern.rs
+++ b/src/pattern.rs
@@ -421,7 +421,7 @@ impl Pattern {
while !pattern.is_resolved() {
if let Some(ref node_id) = fallback {
- match acquired_nodes.acquire(&node_id) {
+ match acquired_nodes.acquire(node_id) {
Ok(acquired) => {
let acquired_node = acquired.get();
@@ -431,7 +431,7 @@ impl Pattern {
match *acquired_node.borrow_element() {
Element::Pattern(ref p) => {
- let unresolved = p.get_unresolved(&acquired_node);
+ let unresolved = p.get_unresolved(acquired_node);
pattern = pattern.resolve_from_fallback(&unresolved.pattern);
fallback = unresolved.fallback;
diff --git a/src/shapes.rs b/src/shapes.rs
index 7d261474..b8f0f6f3 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -441,11 +441,11 @@ impl BasicShape for Rect {
let y = self.y.to_user(params);
let w = match self.width {
- LengthOrAuto::Length(l) => l.to_user(¶ms),
+ LengthOrAuto::Length(l) => l.to_user(params),
LengthOrAuto::Auto => 0.0,
};
let h = match self.height {
- LengthOrAuto::Length(l) => l.to_user(¶ms),
+ LengthOrAuto::Length(l) => l.to_user(params),
LengthOrAuto::Auto => 0.0,
};
diff --git a/src/structure.rs b/src/structure.rs
index b9439863..9facec72 100644
--- a/src/structure.rs
+++ b/src/structure.rs
@@ -87,7 +87,7 @@ impl Draw for Switch {
&mut |an, dc| {
if let Some(child) = node.children().filter(|c| c.is_element()).find(|c| {
let elt = c.borrow_element();
- elt.get_cond(&dc.user_language()) && !elt.is_in_error()
+ elt.get_cond(dc.user_language()) && !elt.is_in_error()
}) {
child.draw(an, &CascadedValues::new(cascaded, &child), dc, clipping)
} else {
diff --git a/src/surface_utils/shared_surface.rs b/src/surface_utils/shared_surface.rs
index 1fec4f74..9d328923 100644
--- a/src/surface_utils/shared_surface.rs
+++ b/src/surface_utils/shared_surface.rs
@@ -1188,7 +1188,7 @@ impl ImageSurface<Shared> {
pub fn rows(&self) -> Rows<'_> {
Rows {
- surface: &self,
+ surface: self,
next_row: 0,
}
}
diff --git a/src/text.rs b/src/text.rs
index 932f63a2..87410327 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -446,7 +446,7 @@ impl Chars {
dy: f64,
depth: usize,
) {
- if let Some(span) = self.make_span(&node, values, dx, dy, depth) {
+ if let Some(span) = self.make_span(node, values, dx, dy, depth) {
let num_chunks = chunks.len();
assert!(num_chunks > 0);
@@ -481,9 +481,9 @@ impl Text {
let values = cascaded.get();
let view_params = draw_ctx.get_view_params();
- let params = NormalizeParams::new(&values, &view_params);
+ let params = NormalizeParams::new(values, &view_params);
- chunks.push(Chunk::new(&values, Some(x), Some(y)));
+ chunks.push(Chunk::new(values, Some(x), Some(y)));
let dx = self.dx.to_user(¶ms);
let dy = self.dy.to_user(¶ms);
@@ -529,7 +529,7 @@ impl Draw for Text {
) -> Result<BoundingBox, RenderingError> {
let values = cascaded.get();
let view_params = draw_ctx.get_view_params();
- let params = NormalizeParams::new(&values, &view_params);
+ let params = NormalizeParams::new(values, &view_params);
let elt = node.borrow_element();
@@ -557,7 +557,7 @@ impl Draw for Text {
let chunk_x = chunk.x.unwrap_or(x);
let chunk_y = chunk.y.unwrap_or(y);
- let positioned = PositionedChunk::from_measured(&chunk, dc, chunk_x, chunk_y);
+ let positioned = PositionedChunk::from_measured(chunk, dc, chunk_x, chunk_y);
x = positioned.next_chunk_x;
y = positioned.next_chunk_y;
@@ -607,12 +607,7 @@ impl TRef {
if let Ok(acquired) = acquired_nodes.acquire(link) {
let c = acquired.get();
- extract_chars_children_to_chunks_recursively(
- chunks,
- &c,
- Rc::new(values.clone()),
- depth,
- );
+ extract_chars_children_to_chunks_recursively(chunks, c, Rc::new(values.clone()), depth);
} else {
rsvg_log!(
"element {} references a nonexistent text source \"{}\"",
diff --git a/src/xml/mod.rs b/src/xml/mod.rs
index 3e790989..0d91301c 100644
--- a/src/xml/mod.rs
+++ b/src/xml/mod.rs
@@ -194,10 +194,10 @@ impl XmlState {
Context::Style => self.inside_style_start_element(&name),
Context::UnsupportedStyleChild => self.unsupported_style_start_element(&name),
- Context::XInclude(ref ctx) => self.inside_xinclude_start_element(&ctx, &name),
+ Context::XInclude(ref ctx) => self.inside_xinclude_start_element(ctx, &name),
Context::UnsupportedXIncludeChild => self.unsupported_xinclude_start_element(&name),
Context::XIncludeFallback(ref ctx) => {
- self.xinclude_fallback_start_element(&ctx, &name, attrs)
+ self.xinclude_fallback_start_element(ctx, &name, attrs)
}
Context::FatalError(_) => unreachable!(),
@@ -248,7 +248,7 @@ impl XmlState {
Context::XInclude(_) => (),
Context::UnsupportedXIncludeChild => (),
- Context::XIncludeFallback(ref ctx) => self.xinclude_fallback_characters(&ctx, text),
+ Context::XIncludeFallback(ref ctx) => self.xinclude_fallback_characters(ctx, text),
Context::FatalError(_) => (),
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]