diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2012-03-19 14:06:59 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2012-03-19 14:29:39 -0700 |
| commit | 869b2d706493549e1fc4a621fe9a44fa58d83c5c (patch) | |
| tree | 882f79b4939e5ac60fa54a95c9be70a3d10f3605 /src/rustc | |
| parent | bbfa08d9474bd08b03718639ad82315d66097e6e (diff) | |
| download | rust-869b2d706493549e1fc4a621fe9a44fa58d83c5c.tar.gz rust-869b2d706493549e1fc4a621fe9a44fa58d83c5c.zip | |
Send string concatenation to specialized upcall, shave 17s off librustc compile time.
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/back/upcall.rs | 4 | ||||
| -rw-r--r-- | src/rustc/middle/trans/tvec.rs | 11 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index a0bb2c5937d..cf862d3ca44 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -18,6 +18,7 @@ type upcalls = mark: ValueRef, vec_grow: ValueRef, vec_push: ValueRef, + str_concat: ValueRef, cmp_type: ValueRef, log_type: ValueRef, alloc_c_stack: ValueRef, @@ -69,6 +70,9 @@ fn declare_upcalls(targ_cfg: @session::config, dvi("vec_push", [T_ptr(T_ptr(opaque_vec_t)), T_ptr(tydesc_type), T_ptr(T_i8())]), + str_concat: + d("str_concat", [T_ptr(opaque_vec_t), T_ptr(opaque_vec_t)], + T_ptr(opaque_vec_t)), cmp_type: dv("cmp_type", [T_ptr(T_i1()), T_ptr(tydesc_type), diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 34e0ccfaffb..c322e9255e0 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -194,15 +194,16 @@ fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t, fn trans_add(bcx: block, vec_ty: ty::t, lhs: ValueRef, rhs: ValueRef, dest: dest) -> block { let ccx = bcx.ccx(); - let strings = alt ty::get(vec_ty).struct { - ty::ty_str { true } - _ { false } - }; + + if ty::get(vec_ty).struct == ty::ty_str { + let n = Call(bcx, ccx.upcalls.str_concat, [lhs, rhs]); + ret base::store_in_dest(bcx, n, dest); + } + let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); let llunitty = type_of::type_of(ccx, unit_ty); let lhs_fill = get_fill(bcx, lhs); - if strings { lhs_fill = Sub(bcx, lhs_fill, C_int(ccx, 1)); } let rhs_fill = get_fill(bcx, rhs); let new_fill = Add(bcx, lhs_fill, rhs_fill); let {bcx: bcx, val: new_vec_ptr} = alloc_raw(bcx, new_fill, new_fill); |
