Skip to content

Commit 284bb8d

Browse files
committed
---
yaml --- r: 64660 b: refs/heads/snap-stage3 c: bbedbc0 h: refs/heads/master v: v3
1 parent bb1b837 commit 284bb8d

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: cced3c9013e4f8e1202b6088f9d3b564e40cac40
4+
refs/heads/snap-stage3: bbedbc04507ea3a1e87905c4b37c3460b5de1746
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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/snap-stage3/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)