Skip to content

Make CircMap open_ent_count O(1)

yuan requested to merge 0x00A5/arti:issue-325 into main

Draft for issue #325 (closed) .

Since get_mut seems only used here, I did try replacing CircMap::get_mut with CircMap::get by changing CircEnt to wrap RefCell<Sender> instead of Sender in Opening and Open so that a readonly reference to the CircEnt can borrow a mutable reference to the Sender without borrowing the entire CircEnt as mutable. But I later ran into a problem that Send is required. So I guess an Arc<Mutex<Sender> might then be required for the inner value to be Send and interiorly mutable.

I didn't find better ways to get rid of get_mut, so I chose to keep it and make the returned mutable reference updates CircMap counter.

I also find it harder to do pattern matching on a Option<MutCircEnt> which might be a shortcoming of this approach.

Edited by yuan

Merge request reports

Loading