mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
librustc: De-@mut
ScopeInfo::cleanup_paths
This commit is contained in:
parent
89a85e45c5
commit
7acaa73377
@ -1223,7 +1223,7 @@ pub fn simple_block_scope(parent: Option<@mut ScopeInfo>,
|
||||
loop_break: None,
|
||||
loop_label: None,
|
||||
cleanups: RefCell::new(~[]),
|
||||
cleanup_paths: ~[],
|
||||
cleanup_paths: RefCell::new(~[]),
|
||||
landing_pad: None,
|
||||
node_info: node_info,
|
||||
}
|
||||
@ -1253,7 +1253,7 @@ pub fn loop_scope_block(bcx: @Block,
|
||||
loop_break: Some(loop_break),
|
||||
loop_label: loop_label,
|
||||
cleanups: RefCell::new(~[]),
|
||||
cleanup_paths: ~[],
|
||||
cleanup_paths: RefCell::new(~[]),
|
||||
landing_pad: None,
|
||||
node_info: opt_node_info,
|
||||
}), bcx.is_lpad, n, opt_node_info);
|
||||
@ -1333,7 +1333,12 @@ pub fn cleanup_and_leave(bcx: @Block,
|
||||
let mut skip = 0;
|
||||
let mut dest = None;
|
||||
{
|
||||
let r = (*inf).cleanup_paths.rev_iter().find(|cp| cp.target == leave);
|
||||
let cleanup_paths = inf.cleanup_paths.borrow();
|
||||
let r = cleanup_paths.get()
|
||||
.rev_iter()
|
||||
.find(|cp| {
|
||||
cp.target == leave
|
||||
});
|
||||
for cp in r.iter() {
|
||||
let cleanups = inf.cleanups.borrow();
|
||||
if cp.size == cleanups.get().len() {
|
||||
@ -1348,7 +1353,9 @@ pub fn cleanup_and_leave(bcx: @Block,
|
||||
let sub_cx = sub_block(bcx, "cleanup");
|
||||
Br(bcx, sub_cx.llbb);
|
||||
let cleanups = inf.cleanups.borrow();
|
||||
inf.cleanup_paths.push(cleanup_path {
|
||||
let mut cleanup_paths = inf.cleanup_paths
|
||||
.borrow_mut();
|
||||
cleanup_paths.get().push(cleanup_path {
|
||||
target: leave,
|
||||
size: cleanups.get().len(),
|
||||
dest: sub_cx.llbb
|
||||
|
@ -432,8 +432,15 @@ pub struct cleanup_path {
|
||||
|
||||
pub fn shrink_scope_clean(scope_info: &mut ScopeInfo, size: uint) {
|
||||
scope_info.landing_pad = None;
|
||||
scope_info.cleanup_paths = scope_info.cleanup_paths.iter()
|
||||
.take_while(|&cu| cu.size <= size).map(|&x|x).collect();
|
||||
let new_cleanup_paths = {
|
||||
let cleanup_paths = scope_info.cleanup_paths.borrow();
|
||||
cleanup_paths.get()
|
||||
.iter()
|
||||
.take_while(|&cu| cu.size <= size)
|
||||
.map(|&x| x)
|
||||
.collect()
|
||||
};
|
||||
scope_info.cleanup_paths.set(new_cleanup_paths)
|
||||
}
|
||||
|
||||
pub fn grow_scope_clean(scope_info: &mut ScopeInfo) {
|
||||
@ -625,7 +632,7 @@ pub struct ScopeInfo {
|
||||
cleanups: RefCell<~[cleanup]>,
|
||||
// Existing cleanup paths that may be reused, indexed by destination and
|
||||
// cleared when the set of cleanups changes.
|
||||
cleanup_paths: ~[cleanup_path],
|
||||
cleanup_paths: RefCell<~[cleanup_path]>,
|
||||
// Unwinding landing pad. Also cleared when cleanups change.
|
||||
landing_pad: Option<BasicBlockRef>,
|
||||
// info about the AST node this scope originated from, if any
|
||||
|
Loading…
Reference in New Issue
Block a user