Bug 1552064 - Rust nsStrings shouldn't uselessly reallocate when constructed from a boxed slice. r=nika
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 16 May 2019 14:31:32 +0000
changeset 532942 b2867d2df9a3ddbd1bc3f1127eda13eed334f67d
parent 532941 87212d664f1fc3fa828bf6f6f9e25ca20e5d2a5f
child 532943 6d47ff50d4ac244474605754fab7a39bb3180b40
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1552064
milestone68.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 1552064 - Rust nsStrings shouldn't uselessly reallocate when constructed from a boxed slice. r=nika Differential Revision: https://phabricator.services.mozilla.com/D31369
xpcom/rust/nsstring/src/lib.rs
--- a/xpcom/rust/nsstring/src/lib.rs
+++ b/xpcom/rust/nsstring/src/lib.rs
@@ -921,17 +921,17 @@ macro_rules! define_string_types {
         impl<'a> From<&'a $AString> for $String {
             fn from(s: &'a $AString) -> $String {
                 $String::from(&s[..])
             }
         }
 
         impl From<Box<[$char_t]>> for $String {
             fn from(s: Box<[$char_t]>) -> $String {
-                s.to_vec().into()
+                s.into_vec().into()
             }
         }
 
         impl From<Vec<$char_t>> for $String {
             fn from(mut s: Vec<$char_t>) -> $String {
                 assert!(s.len() < (u32::MAX as usize));
                 if s.is_empty() {
                     return $String::new();