core: Don't call into the runtime to reserve if we have capacity
This commit is contained in:
parent
c0a99790cb
commit
b7b66b6cb3
2 changed files with 7 additions and 2 deletions
|
@ -1504,7 +1504,9 @@ capacity, then no action is taken.
|
|||
* n - The number of bytes to reserve space for
|
||||
"]
|
||||
fn reserve(&s: str, n: uint) {
|
||||
rustrt::str_reserve_shared(s, n);
|
||||
if capacity(s) < n {
|
||||
rustrt::str_reserve_shared(s, n);
|
||||
}
|
||||
}
|
||||
|
||||
#[doc = "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue