[librsvg: 2/10] Reduce extra allocations by using itertools::join instead of std::iter::collect into std::iter::join



commit 4118f41deae281738048b135a2dbfd200745181d
Author: Jordan Petridis <jordanpetridis protonmail com>
Date:   Fri Dec 8 07:11:54 2017 +0200

    Reduce extra allocations by using itertools::join instead of std::iter::collect into std::iter::join.

 rust/Cargo.lock   | 10 ++++++++++
 rust/Cargo.toml   |  1 +
 rust/src/lib.rs   |  1 +
 rust/src/space.rs |  2 +-
 4 files changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 0397ba7..76445df 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -190,6 +190,14 @@ dependencies = [
 ]
 
 [[package]]
+name = "itertools"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+dependencies = [
+ "either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "kernel32-sys"
 version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
@@ -392,6 +400,7 @@ dependencies = [
  "downcast-rs 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "itertools 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "lalrpop 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -507,6 +516,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 "checksum glib-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"cdd7d911c5dc610aabe37caae7d3b9d2cfe6d8f4c85ff4c062f3d6f490e75067"
 "checksum gobject-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"edc95561e538381576425264a4ddd08c65d5da218f10b2a47b4479dd147775da"
 "checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = 
"4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"
+"checksum itertools 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = 
"947aa0b9bb417792efa3936c5dada2d680b3bc27ea6a88ffa062f4c4d86ef8c5"
 "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = 
"7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
 "checksum lalrpop 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = 
"8ebe5a5c90d5edeecb7f62f6ebec0a3d0f6faf4759a052708348cda99fd311a0"
 "checksum lalrpop-intern 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = 
"05410c1e4aff497bdea1ccb274ac35536fda0ee858600df36966502d4f7acbe3"
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index d84d7fa..65e1431 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -12,6 +12,7 @@ downcast-rs = "^1.0.0"
 regex = "^0.2.1"
 lalrpop-util = "0.13.1"
 cssparser = "^0.18.2"
+itertools = "0.7.4"
 
 [dependencies.cairo-sys-rs]
 version = "0.4.0"
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index f3cd46e..94f5234 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -4,6 +4,7 @@ extern crate cssparser;
 extern crate glib;
 extern crate glib_sys;
 extern crate libc;
+extern crate itertools;
 
 #[macro_use]
 extern crate downcast_rs;
diff --git a/rust/src/space.rs b/rust/src/space.rs
index 1b0dd2e..6bae26d 100644
--- a/rust/src/space.rs
+++ b/rust/src/space.rs
@@ -1,5 +1,6 @@
 use libc;
 use glib::translate::*;
+use itertools::Itertools;
 
 #[repr(C)]
 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
@@ -34,7 +35,6 @@ fn normalize_default(s: &str) -> String {
         .collect::<String>()
         // split at whitespace, also trims whitespace.
         .split_whitespace()
-        .collect::<Vec<_>>()
         .join(" ")
 }
 


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