Stop allocating in fmt::Write for nsA[C]String

This commit is contained in:
Michael Layzell 2017-09-27 13:51:02 -04:00
parent bad77b6a20
commit 47df1375c5

View file

@ -988,7 +988,7 @@ impl From<String> for nsCString {
// Support for the write!() macro for appending to nsACStrings // Support for the write!() macro for appending to nsACStrings
impl fmt::Write for nsACString { impl fmt::Write for nsACString {
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
self.append(&nsCString::from(s)); self.append(s);
Ok(()) Ok(())
} }
} }
@ -1106,7 +1106,7 @@ impl fmt::Write for nsAString {
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
// Directly invoke gecko's routines for appending utf8 strings to // Directly invoke gecko's routines for appending utf8 strings to
// nsAString values, to avoid as much overhead as possible // nsAString values, to avoid as much overhead as possible
self.append_utf8(&nsCString::from(s)); self.append_utf8(s);
Ok(()) Ok(())
} }
} }