[librsvg: 2/3] Assume that attributes are normally going to be valid




commit b47777e6e86824b586706e56393070dcbe85042e
Author: Michael Howell <michael notriddle com>
Date:   Wed Jul 6 14:58:22 2022 -0700

    Assume that attributes are normally going to be valid
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/712>

 src/xml/attributes.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/xml/attributes.rs b/src/xml/attributes.rs
index c2c5ac62e..4ac7d6183 100644
--- a/src/xml/attributes.rs
+++ b/src/xml/attributes.rs
@@ -51,7 +51,7 @@ impl Attributes {
         n_attributes: usize,
         attrs: *const *const libc::c_char,
     ) -> Attributes {
-        let mut array = Vec::new();
+        let mut array = Vec::with_capacity(n_attributes);
 
         if n_attributes > 0 && !attrs.is_null() {
             for attr in slice::from_raw_parts(attrs, n_attributes * 5).chunks_exact(5) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]