Bug 1403545 - Stop allocating in fmt::Write for nsA[C]String, r=froydnj
authorMichael Layzell <michael@thelayzells.com>
Wed, 27 Sep 2017 12:19:29 -0700
changeset 383267 1e3c2c6f12d16798d2ca82f597205d854c7a5f82
parent 383266 76abb09a9d97478a4f3db5257d570000de818e27
child 383268 5d5d1d2271049d89c79f32b295b5859a5ffe7950
push id32587
push userarchaeopteryx@coole-files.de
push dateWed, 27 Sep 2017 21:55:32 +0000
treeherdermozilla-central@69e3f8981645 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1403545
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1403545 - Stop allocating in fmt::Write for nsA[C]String, r=froydnj MozReview-Commit-ID: 6EOJ8QBrwXK
xpcom/rust/nsstring/src/lib.rs
--- a/xpcom/rust/nsstring/src/lib.rs
+++ b/xpcom/rust/nsstring/src/lib.rs
@@ -979,17 +979,17 @@ impl From<String> for nsCString {
     fn from(s: String) -> nsCString {
         s.into_bytes().into()
     }
 }
 
 // Support for the write!() macro for appending to nsACStrings
 impl fmt::Write for nsACString {
     fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
-        self.append(&nsCString::from(s));
+        self.append(s);
         Ok(())
     }
 }
 
 impl fmt::Display for nsACString {
     fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
         fmt::Display::fmt(&String::from_utf8_lossy(&self[..]), f)
     }
@@ -1097,17 +1097,17 @@ impl<'a> From<&'a String> for nsString {
     }
 }
 
 // Support for the write!() macro for writing to nsStrings
 impl fmt::Write for nsAString {
     fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
         // Directly invoke gecko's routines for appending utf8 strings to
         // nsAString values, to avoid as much overhead as possible
-        self.append_utf8(&nsCString::from(s));
+        self.append_utf8(s);
         Ok(())
     }
 }
 
 impl fmt::Display for nsAString {
     fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
         fmt::Display::fmt(&String::from_utf16_lossy(&self[..]), f)
     }