libcore: rewrite str::reserve in pure rust.

This commit is contained in:
Erick Tryzelaar 2012-08-27 07:23:55 -07:00
parent 9074d9b581
commit 628b946186
3 changed files with 3 additions and 15 deletions

View File

@ -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);
}
}

View File

@ -141,13 +141,6 @@ vec_reserve_shared(type_desc* ty, rust_vec_box** vp,
reserve_vec_exact(task, vp, n_elts * ty->size);
}
extern "C" CDECL void
str_reserve_shared(rust_vec_box** sp,
size_t n_elts) {
rust_task *task = rust_get_current_task();
reserve_vec_exact(task, sp, n_elts + 1);
}
extern "C" CDECL rust_vec*
rand_seed() {
size_t size = sizeof(ub4) * RANDSIZ;

View File

@ -61,7 +61,6 @@ shape_log_str
start_task
vec_reserve_shared_actual
vec_reserve_shared
str_reserve_shared
task_clear_event_reject
task_wait_event
task_signal_event