Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
perf(tcw3): convert RcBorrowWeak without strong clone
Browse files Browse the repository at this point in the history
This was made possible by a recent addition to `rc-borrow`:
<CAD97/pointer-utils#59>
  • Loading branch information
yvt committed May 27, 2020
1 parent 3f902cd commit e7c3b89
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tcw3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ndarray = "0.13.0"
neo_linked_list = { path = "../support/neo_linked_list" }
owning_ref = "0.4.0"
packed_simd = "0.3.0"
rc-borrow = "1.0.0"
rc-borrow = "1.3.0"
rob = "0.1"
rope = { path = "../support/rope" }
sorted_diff = { path = "../support/sorted_diff" }
Expand Down
3 changes: 1 addition & 2 deletions tcw3/src/ui/views/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1558,8 +1558,7 @@ fn pend_raise_change(inner: RcBorrow<'_, Inner>) {
return;
}

// FIXME: Remove this extra `upgrade`-ing
let inner_weak = Rc::downgrade(&RcBorrow::upgrade(inner));
let inner_weak = RcBorrow::to_weak(inner);

inner.wm.invoke_on_update(move |wm| {
if let Some(inner) = inner_weak.upgrade() {
Expand Down
4 changes: 2 additions & 2 deletions tcw3/src/uicore/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
cell::RefCell,
cmp::{max, min},
pin::Pin,
rc::{Rc, Weak},
rc::Weak,
};

use super::{
Expand Down Expand Up @@ -82,7 +82,7 @@ impl HWndRef<'_> {
pal_wnd_cell.as_ref().unwrap(),
pal::WndAttrs {
listener: Some(Box::new(PalWndListener {
wnd: Rc::downgrade(&RcBorrow::upgrade(self.wnd)),
wnd: RcBorrow::to_weak(self.wnd),
})),
..Default::default()
},
Expand Down

0 comments on commit e7c3b89

Please sign in to comment.