diff options
| author | Fuwn <[email protected]> | 2021-05-20 12:44:19 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-20 12:44:19 +0000 |
| commit | 314ae50b2162c3cda9cb017baae719fa5822d458 (patch) | |
| tree | 8827bfc8796ee2d29aa245777b7709a8bff97f0d | |
| parent | feat(whirl_config): command struct method which converts field to a command line (diff) | |
| download | whirl-314ae50b2162c3cda9cb017baae719fa5822d458.tar.xz whirl-314ae50b2162c3cda9cb017baae719fa5822d458.zip | |
refactor(whirl_server): cut down on the clones
| -rw-r--r-- | whirl_server/src/distributor.rs | 12 | ||||
| -rw-r--r-- | whirl_server/src/hub.rs | 10 |
2 files changed, 9 insertions, 13 deletions
diff --git a/whirl_server/src/distributor.rs b/whirl_server/src/distributor.rs index 897f6ec..22b698b 100644 --- a/whirl_server/src/distributor.rs +++ b/whirl_server/src/distributor.rs @@ -71,10 +71,10 @@ impl Server for Distributor { trace!("sent property update to client"); } SESSINIT => { - username = find_property_in_property_list( + username = (&*find_property_in_property_list( &parse_network_property(msg[3..].to_vec()), VAR_USERNAME, - ).value.clone(); + ).value).to_string(); debug!("received session initialization from {}", username); @@ -97,9 +97,7 @@ impl Server for Distributor { BUDDYLISTUPDATE => { let buddy = BuddyList::parse(msg.to_vec()); debug!("received buddy list update from {}: {}", username, buddy.buddy); - peer.bytes.get_mut().write_all(&BuddyList { - ..buddy.clone() - }.create()).await?; + peer.bytes.get_mut().write_all(&buddy.clone().create()).await?; trace!("sent buddy list notify to {}: {}", username, buddy.buddy); } ROOMIDRQ => { @@ -108,7 +106,7 @@ impl Server for Distributor { let room_id; if !room_ids.contains(&room.room_name) { - room_ids.push(room.room_name.clone()); + room_ids.push((&*room.room_name).to_string()); room_id = room_ids.iter().position(|r| r == &room.room_name).unwrap(); trace!("inserted room: {}", room.room_name); } else { @@ -118,7 +116,7 @@ impl Server for Distributor { } peer.bytes.get_mut().write_all(&RedirectId { - room_name: room.room_name.clone(), + room_name: (&*room.room_name).to_string(), room_number: room_id as i8, }.create()).await?; trace!("sent redirect id to {}: {}", username, room.room_name); diff --git a/whirl_server/src/hub.rs b/whirl_server/src/hub.rs index 134fc08..6de4bca 100644 --- a/whirl_server/src/hub.rs +++ b/whirl_server/src/hub.rs @@ -70,10 +70,10 @@ impl Server for Hub { trace!("sent property update to client"); } SESSINIT => { - username = find_property_in_property_list( + username = (&*find_property_in_property_list( &parse_network_property(msg[3..].to_vec()), VAR_USERNAME, - ).value.clone(); + ).value).to_string(); debug!("received session initialization from {}", username); @@ -96,9 +96,7 @@ impl Server for Hub { BUDDYLISTUPDATE => { let buddy = BuddyList::parse(msg.to_vec()); debug!("received buddy list update from {}: {}", username, buddy.buddy); - peer.bytes.get_mut().write_all(&BuddyList { - ..buddy.clone() - }.create()).await?; + peer.bytes.get_mut().write_all(&buddy.clone().create()).await?; trace!("sent buddy list notify to {}: {}", username, buddy.buddy); } // TODO: Figure out if this is actually even needed. @@ -116,7 +114,7 @@ impl Server for Hub { { state.lock().await.broadcast(&Text { - sender: username.clone(), + sender: (&*username).to_string(), content: text.content, }.create()).await; } |