File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: c0a99790cb5cf3ba54954b1b8f7c04f54c42f984
2
+ refs/heads/master: b7b66b6cb3aa7b04d611f22d9d0029945e539db1
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
5
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Original file line number Diff line number Diff line change @@ -1504,7 +1504,9 @@ capacity, then no action is taken.
1504
1504
* n - The number of bytes to reserve space for
1505
1505
" ]
1506
1506
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
+ }
1508
1510
}
1509
1511
1510
1512
#[ doc = "
Original file line number Diff line number Diff line change @@ -113,7 +113,10 @@ capacity, then no action is taken.
113
113
* n - The number of elements to reserve space for
114
114
" ]
115
115
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
+ }
117
120
}
118
121
119
122
#[ doc = "
You can’t perform that action at this time.
0 commit comments