mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: cleanup &Arc<dyn T> -> &dyn T
Consuming `&Arc<T>` as argument is almost always an antipattern as it hides whether the callee is going to take over (shared) ownership (by .clone()) or not. Instead, it is better to consume `&dyn T` or `Arc<dyn T>` to be more explicit. This commit cleans up the code. The change is very mechanic and was very easy to implement across the code base. Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
committed by
Rob Bradford
parent
e295719967
commit
7536a95424
@@ -192,12 +192,13 @@ impl Bus {
|
||||
}
|
||||
|
||||
/// Removes all entries referencing the given device.
|
||||
pub fn remove_by_device(&self, device: &Arc<dyn BusDeviceSync>) -> Result<()> {
|
||||
pub fn remove_by_device(&self, device: &dyn BusDeviceSync) -> Result<()> {
|
||||
let mut device_list = self.devices.write().unwrap();
|
||||
let mut remove_key_list = Vec::new();
|
||||
|
||||
for (key, value) in device_list.iter() {
|
||||
if Arc::ptr_eq(&value.upgrade().unwrap(), device) {
|
||||
let value = value.upgrade().unwrap();
|
||||
if core::ptr::eq(Arc::as_ptr(&value), device) {
|
||||
remove_key_list.push(*key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user