diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2012-08-27 07:23:55 -0700 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2012-08-30 20:40:52 -0700 |
| commit | 628b94618695fdf24b5b8cc9f56af6d86efa265d (patch) | |
| tree | 840a678f98c3ce53925a33782413ac5d270ca06a /src/libcore | |
| parent | 9074d9b5813c43cb1d4920dbc9de7dfde032577a (diff) | |
libcore: rewrite str::reserve in pure rust.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/str.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 7e5778f0445..888d992321c 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -115,11 +115,6 @@ export StrSlice, UniqueStr; -#[abi = "cdecl"] -extern mod rustrt { - fn str_reserve_shared(&ss: ~str, nn: libc::size_t); -} - /* Section: Creating a string */ @@ -1818,8 +1813,9 @@ pure fn as_buf<T>(s: &str, f: fn(*u8, uint) -> T) -> T { * * n - The number of bytes to reserve space for */ fn reserve(&s: ~str, n: uint) { - if capacity(s) < n { - rustrt::str_reserve_shared(s, n as size_t); + unsafe { + let v: *mut ~[u8] = ::unsafe::reinterpret_cast(ptr::addr_of(s)); + vec::reserve(*v, n + 1); } } |
