[librsvg: 1/3] micro-optimization: use Box slice instead of Vec for Attributes
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/3] micro-optimization: use Box slice instead of Vec for Attributes
- Date: Thu, 7 Jul 2022 21:12:49 +0000 (UTC)
commit d2c2e539985582e7a06011b4495aa47ebf38747c
Author: Michael Howell <michael notriddle com>
Date: Wed Jul 6 14:53:13 2022 -0700
micro-optimization: use Box slice instead of Vec for Attributes
Part of #706
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/712>
src/xml/attributes.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/xml/attributes.rs b/src/xml/attributes.rs
index 8afa02d8a..c2c5ac62e 100644
--- a/src/xml/attributes.rs
+++ b/src/xml/attributes.rs
@@ -20,7 +20,7 @@ pub type AttributeValue = DefaultAtom;
///
/// [`new_from_xml2_attributes`]: #method.new_from_xml2_attributes
#[derive(Clone)]
-pub struct Attributes(Vec<(QualName, AttributeValue)>);
+pub struct Attributes(Box<[(QualName, AttributeValue)]>);
/// Iterator from `Attributes.iter`.
pub struct AttributesIter<'a>(slice::Iter<'a, (QualName, AttributeValue)>);
@@ -28,7 +28,7 @@ pub struct AttributesIter<'a>(slice::Iter<'a, (QualName, AttributeValue)>);
impl Attributes {
#[cfg(test)]
pub fn new() -> Attributes {
- Attributes(Vec::new())
+ Attributes([].into())
}
/// Creates an iterable `Attributes` from the C array of borrowed C strings.
@@ -92,7 +92,7 @@ impl Attributes {
}
}
- Attributes(array)
+ Attributes(array.into())
}
/// Returns the number of attributes.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]