File tree Expand file tree Collapse file tree 3 files changed +5
-6
lines changed Expand file tree Collapse file tree 3 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
5
5
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
- refs/heads/try2: cced3c9013e4f8e1202b6088f9d3b564e40cac40
8
+ refs/heads/try2: bbedbc04507ea3a1e87905c4b37c3460b5de1746
9
9
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
10
10
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
11
11
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -180,9 +180,7 @@ impl<'self, S: Str> StrVector for &'self [S] {
180
180
181
181
let len = self . iter( ) . transform( |s| s. as_slice( ) . len( ) ) . sum( ) ;
182
182
183
- let mut s = ~"";
184
-
185
- s. reserve( len) ;
183
+ let mut s = with_capacity( len) ;
186
184
187
185
unsafe {
188
186
do s. as_mut_buf |buf, _| {
@@ -678,6 +676,7 @@ pub fn from_utf16(v: &[u16]) -> ~str {
678
676
* Allocates a new string with the specified capacity. The string returned is
679
677
* the empty string, but has capacity for much more.
680
678
*/
679
+ #[ inline]
681
680
pub fn with_capacity ( capacity : uint ) -> ~str {
682
681
let mut buf = ~"";
683
682
buf. reserve ( capacity) ;
@@ -1830,10 +1829,9 @@ impl<'self> StrSlice<'self> for &'self str {
1830
1829
/// Given a string, make a new string with repeated copies of it.
1831
1830
fn repeat(&self, nn: uint) -> ~str {
1832
1831
do self.as_imm_buf |buf, len| {
1833
- let mut ret = ~" ";
1834
1832
// ignore the NULL terminator
1835
1833
let len = len - 1;
1836
- ret.reserve (nn * len);
1834
+ let mut ret = with_capacity (nn * len);
1837
1835
1838
1836
unsafe {
1839
1837
do ret.as_mut_buf |rbuf, _len| {
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
87
87
}
88
88
89
89
/// Creates a new vector with a capacity of `capacity`
90
+ #[ inline]
90
91
pub fn with_capacity < T > ( capacity : uint ) -> ~[ T ] {
91
92
unsafe {
92
93
if contains_managed :: < T > ( ) {
You can’t perform that action at this time.
0 commit comments