Skip to content

Commit 624b074

Browse files
committed
---
yaml --- r: 12189 b: refs/heads/master c: b7b66b6 h: refs/heads/master i: 12187: e1265a6 v: v3
1 parent a21a483 commit 624b074

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: c0a99790cb5cf3ba54954b1b8f7c04f54c42f984
2+
refs/heads/master: b7b66b6cb3aa7b04d611f22d9d0029945e539db1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/str.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,9 @@ capacity, then no action is taken.
15041504
* n - The number of bytes to reserve space for
15051505
"]
15061506
fn reserve(&s: str, n: uint) {
1507-
rustrt::str_reserve_shared(s, n);
1507+
if capacity(s) < n {
1508+
rustrt::str_reserve_shared(s, n);
1509+
}
15081510
}
15091511

15101512
#[doc = "

trunk/src/libcore/vec.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ capacity, then no action is taken.
113113
* n - The number of elements to reserve space for
114114
"]
115115
fn reserve<T>(&v: [const T], n: uint) {
116-
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(), v, n);
116+
// Only make the (slow) call into the runtime if we have to
117+
if capacity(v) < n {
118+
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(), v, n);
119+
}
117120
}
118121

119122
#[doc = "

0 commit comments

Comments
 (0)