[librsvg: 5/10] Use str.replace() instead to convert newlines into spaces.



commit 4e79a87c1b6c3899bcfcecba927888b864657b29
Author: Jordan Petridis <jordanpetridis protonmail com>
Date:   Fri Dec 8 09:40:56 2017 +0200

    Use str.replace() instead to convert newlines into spaces.

 rust/src/space.rs | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/rust/src/space.rs b/rust/src/space.rs
index a82e3ae..5621365 100644
--- a/rust/src/space.rs
+++ b/rust/src/space.rs
@@ -32,9 +32,7 @@ pub fn xml_space_normalize(mode: XmlSpace, s: &str) -> String {
 // characters will be consolidated.
 fn normalize_default<'a, S: Into<Cow<'a, str>>>(s: S) -> String {
     let s = s.into();
-    s.chars()
-        .filter(|ch| *ch != '\n')
-        .collect::<String>()
+    s.replace('\n', "")
         // split at whitespace, also trims whitespace.
         .split_whitespace()
         .join(" ")
@@ -52,8 +50,8 @@ fn normalize_default<'a, S: Into<Cow<'a, str>>>(s: S) -> String {
 // "a b" (one space between "a" and "b").
 fn normalize_preserve<'a, S: Into<Cow<'a, str>>>(s: S) -> String {
     let s = s.into();
-    let s = s.replace("\n", " ");
-    s.replace("\t", " ")
+    let s = s.replace('\n', " ");
+    s.replace('\t', " ")
 }
 
 #[no_mangle]


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