File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -1734,6 +1734,9 @@ impl FromIterator<String> for String {
17341734 fn  from_iter < I :  IntoIterator < Item  = String > > ( iter :  I )  -> String  { 
17351735 let  mut  iterator = iter. into_iter ( ) ; 
17361736
1737+  // Because we're iterating over `String`s, we can avoid at least 
1738+  // one allocation by getting the first string from the iterator 
1739+  // and appending to it all the subsequent strings. 
17371740 match  iterator. next ( )  { 
17381741 None  => String :: new ( ) , 
17391742 Some ( mut  buf)  => { 
@@ -1749,6 +1752,9 @@ impl<'a> FromIterator<Cow<'a, str>> for String {
17491752 fn  from_iter < I :  IntoIterator < Item  = Cow < ' a ,  str > > > ( iter :  I )  -> String  { 
17501753 let  mut  iterator = iter. into_iter ( ) ; 
17511754
1755+  // Because we're iterating over CoWs, we can (potentially) avoid at least 
1756+  // one allocation by getting the first item and appending to it all the 
1757+  // subsequent items. 
17521758 match  iterator. next ( )  { 
17531759 None  => String :: new ( ) , 
17541760 Some ( cow)  => { 
                         You can’t perform that action at this time. 
           
                  
0 commit comments