diff options
| author | bors <bors@rust-lang.org> | 2013-05-10 20:35:00 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-10 20:35:00 -0700 |
| commit | 9f106a643e6cdf2f3c8d62bcec61da087ed24c5b (patch) | |
| tree | b5593b086685c556b08f9772daff3e1391b1356f /src/libstd/workcache.rs | |
| parent | c49cf8b3300a97201058debd63b0f7aef34d3c35 (diff) | |
| parent | 60803e5fc81ed7065c91c0b1725dbbd4da0af3f7 (diff) | |
| download | rust-9f106a643e6cdf2f3c8d62bcec61da087ed24c5b.tar.gz rust-9f106a643e6cdf2f3c8d62bcec61da087ed24c5b.zip | |
auto merge of #6260 : alexcrichton/rust/issue-3466-no-swap, r=pcwalton
There may be a more efficient implementation of `core::util::swap_ptr`. The issue mentioned using `move_val_init`, but I couldn't figure out what that did, so I just used `copy_memory` a few times instead. I'm not exactly the best at reading LLVM generated by rust, but this does appear to be optimized away just as expected (when possible).
Diffstat (limited to 'src/libstd/workcache.rs')
| -rw-r--r-- | src/libstd/workcache.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 9b0a6cb6226..a9e4ec50c7c 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -22,6 +22,7 @@ use core::io; use core::pipes::recv; use core::run; use core::to_bytes; +use core::util::replace; /** * @@ -352,9 +353,7 @@ impl TPrep for Prep { _ => { let (port, chan) = oneshot(); - let mut blk = None; - blk <-> bo; - let blk = blk.unwrap(); + let blk = replace(&mut bo, None).unwrap(); let chan = Cell(chan); do task::spawn { @@ -386,9 +385,7 @@ fn unwrap<T:Owned + Decodable<json::Decoder>>( // FIXME(#5121) w: Work<T>) -> T { let mut ww = w; - let mut s = None; - - ww.res <-> s; + let s = replace(&mut ww.res, None); match s { None => fail!(), |
