[librsvg: 1/3] property_bag: do not store the key string
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/3] property_bag: do not store the key string
- Date: Tue, 18 Dec 2018 17:55:44 +0000 (UTC)
commit caa5007a728e0df237b92d79054f2ab340c64b1d
Author: Paolo Borelli <pborelli gnome org>
Date: Tue Dec 18 09:24:34 2018 +0100
property_bag: do not store the key string
It is not used anywhere anymore, we just need the (attr, value) pair
rsvg_internals/src/clip_path.rs | 2 +-
rsvg_internals/src/create_node.rs | 2 +-
rsvg_internals/src/filters/blend.rs | 2 +-
rsvg_internals/src/filters/color_matrix.rs | 6 +--
rsvg_internals/src/filters/component_transfer.rs | 2 +-
rsvg_internals/src/filters/composite.rs | 2 +-
rsvg_internals/src/filters/convolve_matrix.rs | 8 ++--
rsvg_internals/src/filters/displacement_map.rs | 2 +-
rsvg_internals/src/filters/gaussian_blur.rs | 2 +-
rsvg_internals/src/filters/image.rs | 2 +-
rsvg_internals/src/filters/light/light_source.rs | 2 +-
rsvg_internals/src/filters/light/lighting.rs | 6 +--
rsvg_internals/src/filters/merge.rs | 2 +-
rsvg_internals/src/filters/mod.rs | 4 +-
rsvg_internals/src/filters/morphology.rs | 2 +-
rsvg_internals/src/filters/node.rs | 4 +-
rsvg_internals/src/filters/offset.rs | 2 +-
rsvg_internals/src/filters/turbulence.rs | 2 +-
rsvg_internals/src/gradient.rs | 2 +-
rsvg_internals/src/image.rs | 2 +-
rsvg_internals/src/link.rs | 2 +-
rsvg_internals/src/marker.rs | 2 +-
rsvg_internals/src/mask.rs | 2 +-
rsvg_internals/src/node.rs | 6 +--
rsvg_internals/src/pattern.rs | 2 +-
rsvg_internals/src/property_bag.rs | 51 +++++++++++-------------
rsvg_internals/src/shapes.rs | 12 +++---
rsvg_internals/src/state.rs | 2 +-
rsvg_internals/src/stop.rs | 2 +-
rsvg_internals/src/structure.rs | 6 +--
rsvg_internals/src/style.rs | 2 +-
rsvg_internals/src/text.rs | 6 +--
rsvg_internals/src/xml.rs | 2 +-
33 files changed, 76 insertions(+), 79 deletions(-)
---
diff --git a/rsvg_internals/src/clip_path.rs b/rsvg_internals/src/clip_path.rs
index d674e10f..24d87a91 100644
--- a/rsvg_internals/src/clip_path.rs
+++ b/rsvg_internals/src/clip_path.rs
@@ -80,7 +80,7 @@ impl NodeClipPath {
impl NodeTrait for NodeClipPath {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::ClipPathUnits => self.units.set(parse("clipPathUnits", value, ())?),
diff --git a/rsvg_internals/src/create_node.rs b/rsvg_internals/src/create_node.rs
index fda72e45..086d0973 100644
--- a/rsvg_internals/src/create_node.rs
+++ b/rsvg_internals/src/create_node.rs
@@ -276,7 +276,7 @@ pub fn create_node_and_register_id(
let mut id = None;
let mut class = None;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Id => id = Some(value),
Attribute::Class => class = Some(value),
diff --git a/rsvg_internals/src/filters/blend.rs b/rsvg_internals/src/filters/blend.rs
index 27accc41..91589f3d 100644
--- a/rsvg_internals/src/filters/blend.rs
+++ b/rsvg_internals/src/filters/blend.rs
@@ -53,7 +53,7 @@ impl NodeTrait for Blend {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::In2 => {
self.in2.replace(Some(Input::parse(attr, value)?));
diff --git a/rsvg_internals/src/filters/color_matrix.rs b/rsvg_internals/src/filters/color_matrix.rs
index c0488f83..ed71c5b0 100644
--- a/rsvg_internals/src/filters/color_matrix.rs
+++ b/rsvg_internals/src/filters/color_matrix.rs
@@ -58,7 +58,7 @@ impl NodeTrait for ColorMatrix {
// First, determine the operation type.
let mut operation_type = OperationType::Matrix;
- for (_, attr, value) in pbag.iter().filter(|(_, attr, _)| *attr == Attribute::Type) {
+ for (attr, value) in pbag.iter().filter(|(attr, _)| *attr == Attribute::Type) {
operation_type = OperationType::parse(attr, value)?;
}
@@ -76,9 +76,9 @@ impl NodeTrait for ColorMatrix {
),
);
} else {
- for (_, attr, value) in pbag
+ for (attr, value) in pbag
.iter()
- .filter(|(_, attr, _)| *attr == Attribute::Values)
+ .filter(|(attr, _)| *attr == Attribute::Values)
{
let new_matrix = match operation_type {
OperationType::LuminanceToAlpha => unreachable!(),
diff --git a/rsvg_internals/src/filters/component_transfer.rs
b/rsvg_internals/src/filters/component_transfer.rs
index 0906a7ad..f3b42f34 100644
--- a/rsvg_internals/src/filters/component_transfer.rs
+++ b/rsvg_internals/src/filters/component_transfer.rs
@@ -221,7 +221,7 @@ impl NodeTrait for FuncX {
_handle: *const RsvgHandle,
pbag: &PropertyBag<'_>,
) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Type => self.function_type.set(FunctionType::parse(attr, value)?),
Attribute::TableValues => {
diff --git a/rsvg_internals/src/filters/composite.rs b/rsvg_internals/src/filters/composite.rs
index b86a62aa..509d3eb0 100644
--- a/rsvg_internals/src/filters/composite.rs
+++ b/rsvg_internals/src/filters/composite.rs
@@ -69,7 +69,7 @@ impl NodeTrait for Composite {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::In2 => {
self.in2.replace(Some(Input::parse(Attribute::In2, value)?));
diff --git a/rsvg_internals/src/filters/convolve_matrix.rs b/rsvg_internals/src/filters/convolve_matrix.rs
index 7c48337d..cf4d39e6 100644
--- a/rsvg_internals/src/filters/convolve_matrix.rs
+++ b/rsvg_internals/src/filters/convolve_matrix.rs
@@ -64,7 +64,7 @@ impl NodeTrait for ConvolveMatrix {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Order => self.order.set(
parsers::integer_optional_integer(value)
@@ -124,7 +124,7 @@ impl NodeTrait for ConvolveMatrix {
}
// target_x and target_y depend on order.
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::TargetX => self.target_x.set(Some(
parsers::integer(value)
@@ -167,9 +167,9 @@ impl NodeTrait for ConvolveMatrix {
}
// Finally, parse the kernel matrix.
- for (_, attr, value) in pbag
+ for (attr, value) in pbag
.iter()
- .filter(|(_, attr, _)| *attr == Attribute::KernelMatrix)
+ .filter(|(attr, _)| *attr == Attribute::KernelMatrix)
{
self.kernel_matrix.replace(Some({
let number_of_elements = self.order.get().0 as usize * self.order.get().1 as usize;
diff --git a/rsvg_internals/src/filters/displacement_map.rs b/rsvg_internals/src/filters/displacement_map.rs
index 006879db..bde7bbb6 100644
--- a/rsvg_internals/src/filters/displacement_map.rs
+++ b/rsvg_internals/src/filters/displacement_map.rs
@@ -55,7 +55,7 @@ impl NodeTrait for DisplacementMap {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::In2 => {
self.in2.replace(Some(Input::parse(Attribute::In2, value)?));
diff --git a/rsvg_internals/src/filters/gaussian_blur.rs b/rsvg_internals/src/filters/gaussian_blur.rs
index f508f921..ba782d06 100644
--- a/rsvg_internals/src/filters/gaussian_blur.rs
+++ b/rsvg_internals/src/filters/gaussian_blur.rs
@@ -51,7 +51,7 @@ impl NodeTrait for GaussianBlur {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::StdDeviation => self.std_deviation.set(
parsers::number_optional_number(value)
diff --git a/rsvg_internals/src/filters/image.rs b/rsvg_internals/src/filters/image.rs
index 56dad677..4d84fbe1 100644
--- a/rsvg_internals/src/filters/image.rs
+++ b/rsvg_internals/src/filters/image.rs
@@ -194,7 +194,7 @@ impl NodeTrait for Image {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::PreserveAspectRatio => {
self.aspect.set(parse("preserveAspectRatio", value, ())?)
diff --git a/rsvg_internals/src/filters/light/light_source.rs
b/rsvg_internals/src/filters/light/light_source.rs
index 943d4b07..fc028c3a 100644
--- a/rsvg_internals/src/filters/light/light_source.rs
+++ b/rsvg_internals/src/filters/light/light_source.rs
@@ -207,7 +207,7 @@ impl NodeTrait for LightSource {
_handle: *const RsvgHandle,
pbag: &PropertyBag<'_>,
) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match self {
LightSource::Distant {
ref azimuth,
diff --git a/rsvg_internals/src/filters/light/lighting.rs b/rsvg_internals/src/filters/light/lighting.rs
index 5b3c267b..f654c596 100644
--- a/rsvg_internals/src/filters/light/lighting.rs
+++ b/rsvg_internals/src/filters/light/lighting.rs
@@ -106,7 +106,7 @@ impl NodeTrait for Lighting {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::SurfaceScale => self.surface_scale.set(
parsers::number(value).map_err(|err| NodeError::attribute_error(attr, err))?,
@@ -133,7 +133,7 @@ impl NodeTrait for Lighting {
Data::Diffuse {
ref diffuse_constant,
} => {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::DiffuseConstant => diffuse_constant.set(
parsers::number(value)
@@ -157,7 +157,7 @@ impl NodeTrait for Lighting {
ref specular_constant,
ref specular_exponent,
} => {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::SpecularConstant => specular_constant.set(
parsers::number(value)
diff --git a/rsvg_internals/src/filters/merge.rs b/rsvg_internals/src/filters/merge.rs
index fa5bb8c4..d1e2e86d 100644
--- a/rsvg_internals/src/filters/merge.rs
+++ b/rsvg_internals/src/filters/merge.rs
@@ -63,7 +63,7 @@ impl NodeTrait for MergeNode {
_handle: *const RsvgHandle,
pbag: &PropertyBag<'_>,
) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::In => {
self.in_.replace(Some(Input::parse(Attribute::In, value)?));
diff --git a/rsvg_internals/src/filters/mod.rs b/rsvg_internals/src/filters/mod.rs
index 769091b3..fa17c52f 100644
--- a/rsvg_internals/src/filters/mod.rs
+++ b/rsvg_internals/src/filters/mod.rs
@@ -145,7 +145,7 @@ impl NodeTrait for Primitive {
let check_units_and_ensure_nonnegative =
|length: Length| check_units(length).and_then(Length::check_nonnegative);
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::X => self.x.set(Some(parse_and_validate(
"x",
@@ -210,7 +210,7 @@ impl NodeTrait for PrimitiveWithInput {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::In => drop(self.in_.replace(Some(Input::parse(Attribute::In, value)?))),
_ => (),
diff --git a/rsvg_internals/src/filters/morphology.rs b/rsvg_internals/src/filters/morphology.rs
index 3e43a614..07cdbb64 100644
--- a/rsvg_internals/src/filters/morphology.rs
+++ b/rsvg_internals/src/filters/morphology.rs
@@ -56,7 +56,7 @@ impl NodeTrait for Morphology {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Operator => self.operator.set(Operator::parse(attr, value)?),
Attribute::Radius => self.radius.set(
diff --git a/rsvg_internals/src/filters/node.rs b/rsvg_internals/src/filters/node.rs
index 1612d681..dd4eb522 100644
--- a/rsvg_internals/src/filters/node.rs
+++ b/rsvg_internals/src/filters/node.rs
@@ -43,7 +43,7 @@ impl NodeTrait for NodeFilter {
pbag: &PropertyBag<'_>,
) -> NodeResult {
// Parse filterUnits first as it affects x, y, width, height checks.
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::FilterUnits => self.filterunits.set(parse("filterUnits", value, ())?),
_ => (),
@@ -68,7 +68,7 @@ impl NodeTrait for NodeFilter {
|length: Length| check_units(length).and_then(Length::check_nonnegative);
// Parse the rest of the attributes.
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::X => self.x.set(parse_and_validate(
"x",
diff --git a/rsvg_internals/src/filters/offset.rs b/rsvg_internals/src/filters/offset.rs
index 2b85c2d8..0180004c 100644
--- a/rsvg_internals/src/filters/offset.rs
+++ b/rsvg_internals/src/filters/offset.rs
@@ -43,7 +43,7 @@ impl NodeTrait for Offset {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Dx => self.dx.set(
parsers::number(value).map_err(|err| NodeError::attribute_error(attr, err))?,
diff --git a/rsvg_internals/src/filters/turbulence.rs b/rsvg_internals/src/filters/turbulence.rs
index a5eebdf9..bc9b705f 100644
--- a/rsvg_internals/src/filters/turbulence.rs
+++ b/rsvg_internals/src/filters/turbulence.rs
@@ -69,7 +69,7 @@ impl NodeTrait for Turbulence {
) -> NodeResult {
self.base.set_atts(node, handle, pbag)?;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::BaseFrequency => self.base_frequency.set(
parsers::number_optional_number(value)
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 2e8867b1..73c11651 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -656,7 +656,7 @@ impl NodeTrait for NodeGradient {
let mut fx = None;
let mut fy = None;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
// Attributes common to linear and radial gradients
Attribute::GradientUnits => {
diff --git a/rsvg_internals/src/image.rs b/rsvg_internals/src/image.rs
index 2b3cda1c..602e98ab 100644
--- a/rsvg_internals/src/image.rs
+++ b/rsvg_internals/src/image.rs
@@ -49,7 +49,7 @@ impl NodeTrait for NodeImage {
// https://www.w3.org/TR/SVG/styling.html#UAStyleSheet
node.set_overflow_hidden();
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal)?),
Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical)?),
diff --git a/rsvg_internals/src/link.rs b/rsvg_internals/src/link.rs
index 32b92818..fd0ee488 100644
--- a/rsvg_internals/src/link.rs
+++ b/rsvg_internals/src/link.rs
@@ -28,7 +28,7 @@ impl NodeLink {
impl NodeTrait for NodeLink {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::XlinkHref => *self.link.borrow_mut() = Some(value.to_owned()),
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index 8bbb3616..79e690d3 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -218,7 +218,7 @@ impl NodeTrait for NodeMarker {
// https://www.w3.org/TR/SVG/styling.html#UAStyleSheet
node.set_overflow_hidden();
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::MarkerUnits => self.units.set(parse("markerUnits", value, ())?),
diff --git a/rsvg_internals/src/mask.rs b/rsvg_internals/src/mask.rs
index 11ff7c7a..965b0ef4 100644
--- a/rsvg_internals/src/mask.rs
+++ b/rsvg_internals/src/mask.rs
@@ -235,7 +235,7 @@ fn compute_luminance_to_alpha(
impl NodeTrait for NodeMask {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal)?),
Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical)?),
diff --git a/rsvg_internals/src/node.rs b/rsvg_internals/src/node.rs
index 4b15b286..745adcc6 100644
--- a/rsvg_internals/src/node.rs
+++ b/rsvg_internals/src/node.rs
@@ -354,7 +354,7 @@ impl Node {
}
pub fn set_atts(&self, node: &RsvgNode, handle: *const RsvgHandle, pbag: &PropertyBag<'_>) {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Transform => match Matrix::parse_str(value, ()) {
Ok(affine) => self.data.transform.set(affine),
@@ -391,7 +391,7 @@ impl Node {
) -> Result<(), NodeError> {
let mut cond = self.get_cond();
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
// FIXME: move this to "do catch" when we can bump the rustc version dependency
let mut parse = || {
match attr {
@@ -513,7 +513,7 @@ impl Node {
/// Looks for the "style" attribute in the pbag, and applies CSS styles from it
fn set_style_attribute(&self, pbag: &PropertyBag<'_>) {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Style => {
let mut state = self.data.state.borrow_mut();
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index df144b59..9064dd6d 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -187,7 +187,7 @@ impl NodeTrait for NodePattern {
p.node = Some(Rc::downgrade(node));
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::PatternUnits => p.units = Some(parse("patternUnits", value, ())?),
diff --git a/rsvg_internals/src/property_bag.rs b/rsvg_internals/src/property_bag.rs
index 96ac0fe6..e9f58881 100644
--- a/rsvg_internals/src/property_bag.rs
+++ b/rsvg_internals/src/property_bag.rs
@@ -7,14 +7,13 @@ use std::str::{self, FromStr};
use attributes::Attribute;
-// We store (key, attribute, value)
-pub struct PropertyBag<'a>(Vec<(&'a CStr, Attribute, &'a CStr)>);
+pub struct PropertyBag<'a>(Vec<(Attribute, &'a CStr)>);
-pub struct OwnedPropertyBag(Vec<(CString, Attribute, CString)>);
+pub struct OwnedPropertyBag(Vec<(Attribute, CString)>);
pub struct PropertyBagIter<'a>(PropertyBagCStrIter<'a>);
-pub struct PropertyBagCStrIter<'a>(slice::Iter<'a, (&'a CStr, Attribute, &'a CStr)>);
+pub struct PropertyBagCStrIter<'a>(slice::Iter<'a, (Attribute, &'a CStr)>);
trait Utf8CStrToStr {
fn to_str_utf8(&self) -> &str;
@@ -66,7 +65,7 @@ impl<'a> PropertyBag<'a> {
// We silently drop unknown attributes. New attributes should be added in
// build.rs.
if let Ok(attr) = Attribute::from_str(key_str.to_str_utf8()) {
- array.push((key_str, attr, val_str));
+ array.push((attr, val_str));
}
} else {
break;
@@ -82,18 +81,18 @@ impl<'a> PropertyBag<'a> {
pub fn from_owned(owned: &OwnedPropertyBag) -> PropertyBag<'_> {
let mut array = Vec::new();
- for &(ref k, a, ref v) in &owned.0 {
- array.push((k.deref(), a, v.deref()));
+ for &(a, ref v) in &owned.0 {
+ array.push((a, v.deref()));
}
PropertyBag(array)
}
pub fn to_owned(&self) -> OwnedPropertyBag {
- let mut array = Vec::<(CString, Attribute, CString)>::new();
+ let mut array = Vec::<(Attribute, CString)>::new();
- for &(k, a, v) in &self.0 {
- array.push(((*k).to_owned(), a, (*v).to_owned()));
+ for &(a, v) in &self.0 {
+ array.push((a, (*v).to_owned()));
}
OwnedPropertyBag(array)
@@ -117,20 +116,18 @@ impl<'a> PropertyBag<'a> {
}
impl<'a> Iterator for PropertyBagIter<'a> {
- type Item = (&'a str, Attribute, &'a str);
+ type Item = (Attribute, &'a str);
fn next(&mut self) -> Option<Self::Item> {
- self.0
- .next()
- .map(|(k, a, v)| (k.to_str_utf8(), a, v.to_str_utf8()))
+ self.0.next().map(|(a, v)| (a, v.to_str_utf8()))
}
}
impl<'a> Iterator for PropertyBagCStrIter<'a> {
- type Item = (&'a CStr, Attribute, &'a CStr);
+ type Item = (Attribute, &'a CStr);
fn next(&mut self) -> Option<Self::Item> {
- self.0.next().map(|&(k, a, v)| (k, a, v))
+ self.0.next().map(|&(a, v)| (a, v))
}
}
@@ -168,17 +165,17 @@ mod tests {
let mut had_rx: bool = false;
let mut had_ry: bool = false;
- for (k, a, v) in pbag.iter() {
- if k == "rx" {
- assert!(a == Attribute::Rx);
- assert!(v == "1");
- had_rx = true;
- } else if k == "ry" {
- assert!(a == Attribute::Ry);
- assert!(v == "2");
- had_ry = true;
- } else {
- unreachable!();
+ for (a, v) in pbag.iter() {
+ match a {
+ Attribute::Rx => {
+ assert!(v == "1");
+ had_rx = true;
+ }
+ Attribute::Ry => {
+ assert!(v == "2");
+ had_ry = true;
+ }
+ _ => unreachable!()
}
}
diff --git a/rsvg_internals/src/shapes.rs b/rsvg_internals/src/shapes.rs
index 1c581721..845c1b12 100644
--- a/rsvg_internals/src/shapes.rs
+++ b/rsvg_internals/src/shapes.rs
@@ -129,7 +129,7 @@ impl NodeTrait for NodePath {
_: *const RsvgHandle,
pbag: &PropertyBag<'_>,
) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
if attr == Attribute::D {
let mut builder = PathBuilder::new();
@@ -197,7 +197,7 @@ impl NodePoly {
impl NodeTrait for NodePoly {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
// support for svg < 1.0 which used verts
if attr == Attribute::Points || attr == Attribute::Verts {
let result = parsers::list_of_points(value.trim());
@@ -269,7 +269,7 @@ impl NodeLine {
impl NodeTrait for NodeLine {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::X1 => self.x1.set(parse("x1", value, LengthDir::Horizontal)?),
Attribute::Y1 => self.y1.set(parse("y1", value, LengthDir::Vertical)?),
@@ -335,7 +335,7 @@ impl NodeRect {
impl NodeTrait for NodeRect {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal)?),
Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical)?),
@@ -539,7 +539,7 @@ impl NodeCircle {
impl NodeTrait for NodeCircle {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Cx => self.cx.set(parse("cx", value, LengthDir::Horizontal)?),
Attribute::Cy => self.cy.set(parse("cy", value, LengthDir::Vertical)?),
@@ -596,7 +596,7 @@ impl NodeEllipse {
impl NodeTrait for NodeEllipse {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Cx => self.cx.set(parse("cx", value, LengthDir::Horizontal)?),
Attribute::Cy => self.cy.set(parse("cy", value, LengthDir::Vertical)?),
diff --git a/rsvg_internals/src/state.rs b/rsvg_internals/src/state.rs
index 753f21c7..a73ebd3a 100644
--- a/rsvg_internals/src/state.rs
+++ b/rsvg_internals/src/state.rs
@@ -536,7 +536,7 @@ impl State {
&mut self,
pbag: &PropertyBag<'_>,
) -> Result<(), NodeError> {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
self.parse_attribute_pair(attr, value, false)?;
}
diff --git a/rsvg_internals/src/stop.rs b/rsvg_internals/src/stop.rs
index 7b6d0e60..f3b070e1 100644
--- a/rsvg_internals/src/stop.rs
+++ b/rsvg_internals/src/stop.rs
@@ -46,7 +46,7 @@ fn validate_offset(length: Length) -> Result<Length, ValueErrorKind> {
impl NodeTrait for NodeStop {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Offset => {
let length =
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 7aaf123f..f077555b 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -141,7 +141,7 @@ impl NodeTrait for NodeSvg {
// http://www.w3.org/TR/SVG/struct.html#SVGElement
let is_inner_svg = node.get_parent().is_some();
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::PreserveAspectRatio => {
self.preserve_aspect_ratio
@@ -249,7 +249,7 @@ impl NodeUse {
impl NodeTrait for NodeUse {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::XlinkHref => {
*self.link.borrow_mut() =
@@ -419,7 +419,7 @@ impl NodeTrait for NodeSymbol {
// https://www.w3.org/TR/SVG/styling.html#UAStyleSheet
node.set_overflow_hidden();
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::PreserveAspectRatio => {
self.preserve_aspect_ratio
diff --git a/rsvg_internals/src/style.rs b/rsvg_internals/src/style.rs
index 55b93fc8..2d9bd880 100644
--- a/rsvg_internals/src/style.rs
+++ b/rsvg_internals/src/style.rs
@@ -57,7 +57,7 @@ impl NodeStyle {
impl NodeTrait for NodeStyle {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
if attr == Attribute::Type {
*self.type_.borrow_mut() = Some(value.to_string());
}
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 5e6a4d41..7a37c55f 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -168,7 +168,7 @@ impl NodeText {
impl NodeTrait for NodeText {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal)?),
Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical)?),
@@ -303,7 +303,7 @@ impl NodeTRef {
impl NodeTrait for NodeTRef {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::XlinkHref => {
*self.link.borrow_mut() =
@@ -413,7 +413,7 @@ impl NodeTSpan {
impl NodeTrait for NodeTSpan {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::X => self
.x
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index b6a41a8f..0c35a2f6 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -382,7 +382,7 @@ impl XmlState {
let mut parse = None;
let mut encoding = None;
- for (_key, attr, value) in pbag.iter() {
+ for (attr, value) in pbag.iter() {
match attr {
Attribute::Href => href = Some(value),
Attribute::Parse => parse = Some(value),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]