Skip to content

Commit 590a01e

Browse files
committed
---
yaml --- r: 143214 b: refs/heads/try2 c: bbedbc0 h: refs/heads/master v: v3
1 parent 3f02e00 commit 590a01e

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: cced3c9013e4f8e1202b6088f9d3b564e40cac40
8+
refs/heads/try2: bbedbc04507ea3a1e87905c4b37c3460b5de1746
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/str.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ impl<'self, S: Str> StrVector for &'self [S] {
180180

181181
let len = self.iter().transform(|s| s.as_slice().len()).sum();
182182

183-
let mut s = ~"";
184-
185-
s.reserve(len);
183+
let mut s = with_capacity(len);
186184

187185
unsafe {
188186
do s.as_mut_buf |buf, _| {
@@ -678,6 +676,7 @@ pub fn from_utf16(v: &[u16]) -> ~str {
678676
* Allocates a new string with the specified capacity. The string returned is
679677
* the empty string, but has capacity for much more.
680678
*/
679+
#[inline]
681680
pub fn with_capacity(capacity: uint) -> ~str {
682681
let mut buf = ~"";
683682
buf.reserve(capacity);
@@ -1830,10 +1829,9 @@ impl<'self> StrSlice<'self> for &'self str {
18301829
/// Given a string, make a new string with repeated copies of it.
18311830
fn repeat(&self, nn: uint) -> ~str {
18321831
do self.as_imm_buf |buf, len| {
1833-
let mut ret = ~"";
18341832
// ignore the NULL terminator
18351833
let len = len - 1;
1836-
ret.reserve(nn * len);
1834+
let mut ret = with_capacity(nn * len);
18371835
18381836
unsafe {
18391837
do ret.as_mut_buf |rbuf, _len| {

branches/try2/src/libstd/vec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
8787
}
8888

8989
/// Creates a new vector with a capacity of `capacity`
90+
#[inline]
9091
pub fn with_capacity<T>(capacity: uint) -> ~[T] {
9192
unsafe {
9293
if contains_managed::<T>() {

0 commit comments

Comments
 (0)