misc: Use deref operator for RefCell instead of clone or as_ref

This commit is contained in:
Kévin Commaille 2023-12-20 17:36:15 +01:00
parent af547243a7
commit c0eab643b4
No known key found for this signature in database
GPG Key ID: 29A48C1F03620416
19 changed files with 27 additions and 27 deletions

View File

@ -87,7 +87,7 @@ mod imp {
/// Set the [`AvatarData`] displayed by this widget.
fn set_data(&self, data: Option<AvatarData>) {
if self.data.borrow().as_ref() == data.as_ref() {
if *self.data.borrow() == data {
return;
}

View File

@ -118,7 +118,7 @@ mod imp {
impl ContextMenuBin {
/// Set the popover displaying the context menu.
fn set_popover(&self, popover: Option<gtk::PopoverMenu>) {
if self.popover.borrow().as_ref() == popover.as_ref() {
if *self.popover.borrow() == popover {
return;
}

View File

@ -139,7 +139,7 @@ mod imp {
impl EditableAvatar {
/// Set the [`AvatarData`] to display.
fn set_data(&self, data: Option<AvatarData>) {
if self.data.borrow().as_ref() == data.as_ref() {
if *self.data.borrow() == data {
return;
}

View File

@ -91,7 +91,7 @@ mod imp {
impl LabelWithWidgets {
/// Set the text of the label.
fn set_label(&self, label: Option<String>) {
if self.label.borrow().as_ref() == label.as_ref() {
if *self.label.borrow() == label {
return;
}
@ -104,7 +104,7 @@ mod imp {
/// Set the placeholder that is replaced with widgets.
fn set_placeholder(&self, placeholder: Option<String>) {
if self.placeholder.borrow().as_ref() == placeholder.as_ref() {
if *self.placeholder.borrow() == placeholder {
return;
}
@ -187,7 +187,7 @@ impl LabelWithWidgets {
}
pub fn widgets(&self) -> Vec<gtk::Widget> {
self.imp().widgets.borrow().to_owned()
self.imp().widgets.borrow().clone()
}
fn invalidate_child_widgets(&self) {

View File

@ -252,7 +252,7 @@ impl Login {
fn set_domain(&self, domain: Option<OwnedServerName>) {
let imp = self.imp();
if imp.domain.borrow().as_ref() == domain.as_ref() {
if *imp.domain.borrow() == domain {
return;
}

View File

@ -82,7 +82,7 @@ mod imp {
fn set_uri(&self, uri: Option<String>) {
let uri = uri.map(OwnedMxcUri::from);
if self.uri.borrow().as_ref() == uri.as_ref() {
if *self.uri.borrow() == uri {
return;
}
let obj = self.obj();

View File

@ -37,7 +37,7 @@ mod imp {
impl AvatarData {
/// Set the data of the user-defined image.
fn set_image(&self, image: Option<AvatarImage>) {
if self.image.borrow().as_ref() == image.as_ref() {
if *self.image.borrow() == image {
return;
}
@ -47,7 +47,7 @@ mod imp {
/// Set the display name used as a fallback for this avatar.
fn set_display_name(&self, display_name: Option<String>) {
if self.display_name.borrow().as_ref() == display_name.as_ref() {
if *self.display_name.borrow() == display_name {
return;
}

View File

@ -161,7 +161,7 @@ mod imp {
/// Set the selected item.
fn set_selected_item(&self, item: Option<glib::Object>) {
if self.selected_item.borrow().as_ref() == item.as_ref() {
if *self.selected_item.borrow() == item {
return;
}
let obj = self.obj();

View File

@ -150,7 +150,7 @@ impl ImportExportKeysSubpage {
/// Set the path to export the keys to.
fn set_file_path(&self, path: Option<gio::File>) {
let imp = self.imp();
if imp.file_path.borrow().as_ref() == path.as_ref() {
if *imp.file_path.borrow() == path {
return;
}

View File

@ -199,9 +199,9 @@ impl PublicRoomList {
network: Option<String>,
) -> bool {
let imp = self.imp();
imp.search_term.borrow().as_ref() == search_term.as_ref()
&& imp.server.borrow().as_ref() == server.as_ref()
&& imp.network.borrow().as_ref() == network.as_ref()
*imp.search_term.borrow() == search_term
&& *imp.server.borrow() == server
&& *imp.network.borrow() == network
}
pub fn load_public_rooms(&self, clear: bool) {
@ -228,9 +228,9 @@ impl PublicRoomList {
}
let client = self.session().unwrap().client();
let search_term = imp.search_term.borrow().to_owned();
let server = imp.server.borrow().to_owned();
let network = imp.network.borrow().to_owned();
let search_term = imp.search_term.borrow().clone();
let server = imp.server.borrow().clone();
let network = imp.network.borrow().clone();
let current_search_term = search_term.clone();
let current_server = server.clone();
let current_network = network.clone();

View File

@ -64,7 +64,7 @@ mod imp {
impl AudioRow {
/// Set the audio event.
fn set_event(&self, event: Option<HistoryViewerEvent>) {
if self.event.borrow().clone() == event {
if *self.event.borrow() == event {
return;
}
let obj = self.obj();

View File

@ -67,7 +67,7 @@ mod imp {
impl FileRow {
/// Set the file event.
fn set_event(&self, event: Option<HistoryViewerEvent>) {
if self.event.borrow().clone() == event {
if *self.event.borrow() == event {
return;
}

View File

@ -82,7 +82,7 @@ mod imp {
impl MediaItem {
/// Set the media event.
fn set_event(&self, event: Option<HistoryViewerEvent>) {
if self.event.borrow().clone() == event {
if *self.event.borrow() == event {
return;
}
let obj = self.obj();

View File

@ -73,7 +73,7 @@ mod imp {
fn set_search_term(&self, search_term: Option<String>) {
let search_term = search_term.filter(|s| !s.is_empty());
if search_term.as_ref() == self.search_term.borrow().as_ref() {
if search_term == *self.search_term.borrow() {
return;
}
let obj = self.obj();

View File

@ -42,7 +42,7 @@ mod imp {
impl DmUserRow {
/// Set the user displayed by this row.
fn set_user(&self, user: Option<DmUser>) {
if self.user.borrow().clone() == user {
if *self.user.borrow() == user {
return;
}

View File

@ -65,7 +65,7 @@ mod imp {
impl CategoryRow {
/// Set the category represented by this row.
fn set_category(&self, category: Option<Category>) {
if self.category.borrow().clone() == category {
if *self.category.borrow() == category {
return;
}

View File

@ -44,7 +44,7 @@ mod imp {
impl IconItemRow {
/// Set the [`IconItem`] of this row.
fn set_icon_item(&self, icon_item: Option<IconItem>) {
if self.icon_item.borrow().clone() == icon_item {
if *self.icon_item.borrow() == icon_item {
return;
}
let obj = self.obj();

View File

@ -96,7 +96,7 @@ mod imp {
/// Set the list row to track for expander state.
fn set_list_row(&self, list_row: Option<gtk::TreeListRow>) {
if self.list_row.borrow().clone() == list_row {
if *self.list_row.borrow() == list_row {
return;
}
let obj = self.obj();

View File

@ -43,7 +43,7 @@ mod imp {
impl VerificationRow {
/// Set the identity verification represented by this row.
fn set_identity_verification(&self, verification: Option<IdentityVerification>) {
if self.identity_verification.borrow().clone() == verification {
if *self.identity_verification.borrow() == verification {
return;
}