Skip to content

Commit e546c48

Browse files
committed
rustc: Don't copy vecs in seq_preconds. Huge perf win on some tests
Compile time for the included test goes from 5min to 18s.
1 parent 09b9447 commit e546c48

File tree

2 files changed

+8008
-5
lines changed

2 files changed

+8008
-5
lines changed

src/rustc/middle/tstate/bitvectors.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ fn seq_preconds(fcx: fn_ctxt, pps: [pre_and_post]) -> precond {
8080
let sz: uint = vec::len(pps);
8181
let num_vars: uint = num_constraints(fcx.enclosing);
8282

83-
fn seq_preconds_go(fcx: fn_ctxt, pps: [pre_and_post], first: pre_and_post)
83+
fn seq_preconds_go(fcx: fn_ctxt, pps: [pre_and_post],
84+
idx: uint, first: pre_and_post)
8485
-> precond {
85-
let mut pps = pps;
86+
let mut idx = idx;
8687
let mut first = first;
8788
loop {
88-
let sz: uint = vec::len(pps);
89+
let sz: uint = vec::len(pps) - idx;
8990
if sz >= 1u {
9091
let second = pps[0];
9192
assert (pps_len(second) == num_constraints(fcx.enclosing));
@@ -95,7 +96,7 @@ fn seq_preconds(fcx: fn_ctxt, pps: [pre_and_post]) -> precond {
9596
union(next_first, second_pre);
9697
let next_first_post = clone(first.postcondition);
9798
seq_tritv(next_first_post, second.postcondition);
98-
pps = vec::slice(pps, 1u, sz);
99+
idx += 1u;
99100
first = @{precondition: next_first,
100101
postcondition: next_first_post};
101102
} else { ret first.precondition; }
@@ -105,7 +106,7 @@ fn seq_preconds(fcx: fn_ctxt, pps: [pre_and_post]) -> precond {
105106
if sz >= 1u {
106107
let first = pps[0];
107108
assert (pps_len(first) == num_vars);
108-
ret seq_preconds_go(fcx, vec::slice(pps, 1u, sz), first);
109+
ret seq_preconds_go(fcx, pps, 1u, first);
109110
} else { ret true_precond(num_vars); }
110111
}
111112

0 commit comments

Comments
 (0)