[librsvg/wip/aruiz/rust-pixbuf-loader: 62/69] pixbuf-loader: Avoid extra copy by turning slice into Bytes without to_vec()




commit 1911941739bf57d070968c7f54d7ce95bdf4a188
Author: Alberto Ruiz <aruiz redhat com>
Date:   Fri Aug 5 23:40:04 2022 +0100

    pixbuf-loader: Avoid extra copy by turning slice into Bytes without to_vec()
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/722>

 gdk-pixbuf-loader/src/lib.rs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
---
diff --git a/gdk-pixbuf-loader/src/lib.rs b/gdk-pixbuf-loader/src/lib.rs
index af94e6612..f1579ef26 100644
--- a/gdk-pixbuf-loader/src/lib.rs
+++ b/gdk-pixbuf-loader/src/lib.rs
@@ -64,8 +64,7 @@ unsafe extern "C" fn load_increment(
     let ctx = user_data as *mut SvgContext;
 
     let data = std::slice::from_raw_parts(buffer, size as usize);
-    let data = data.to_vec();
-    (&*ctx).stream.add_bytes(&Bytes::from_owned(data));
+    (&*ctx).stream.add_bytes(&Bytes::from(data));
     true.into_glib()
 }
 


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