servo: Merge #18656 - Stop allocating in fmt::Write for nsA[C]String (from mystor:bug1403545); r=emilio

<!-- Please describe your changes on the following line: -->
This is the servo side of gecko bug 1403545 https://bugzilla.mozilla.org/show_bug.cgi?id=1403545. It's fixing a stylo perf regression caused by #18642

It has already been reviewed on the gecko side by froydnj

Source-Repo: https://github.com/servo/servo
Source-Revision: 35ad0316f6fc517e1f4ba0b0a4a4b2bcd1646656

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 0447db686da0ddc61a9433ab80f9d90d1ad4fc4d
This commit is contained in:
Michael Layzell 2017-09-27 13:00:54 -05:00
Родитель c4c2d7f604
Коммит 6cf8c01c78
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -988,7 +988,7 @@ impl From<String> for nsCString {
// 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(())
}
}
@ -1106,7 +1106,7 @@ 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(())
}
}