Skip to content

Commit

Permalink
Simplify inner_try in std::rt::unwind::try
Browse files Browse the repository at this point in the history
Resolve the TLS PANICKING variable just once and re-use it as needed.
  • Loading branch information
ranma42 committed Sep 22, 2015
1 parent f07f4ef commit cf10296
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/libstd/sys/common/unwind/mod.rs
Expand Up @@ -148,15 +148,17 @@ pub unsafe fn try<F: FnOnce()>(f: F) -> Result<(), Box<Any + Send>> {
// care of exposing correctly.
unsafe fn inner_try(f: fn(*mut u8), data: *mut u8)
-> Result<(), Box<Any + Send>> {
let prev = PANICKING.with(|s| s.get());
PANICKING.with(|s| s.set(false));
let ep = intrinsics::try(f, data);
PANICKING.with(|s| s.set(prev));
if ep.is_null() {
Ok(())
} else {
Err(imp::cleanup(ep))
}
PANICKING.with(|s| {
let prev = s.get();
s.set(false);
let ep = intrinsics::try(f, data);
s.set(prev);
if ep.is_null() {
Ok(())
} else {
Err(imp::cleanup(ep))
}
})
}

fn try_fn<F: FnOnce()>(opt_closure: *mut u8) {
Expand Down

0 comments on commit cf10296

Please sign in to comment.