Skip to content

Commit

Permalink
Remove unnecessary Vec in WsClient (#2705)
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Feb 9, 2024
1 parent 360f421 commit 90fbc11
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/gateway/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct PresenceUpdateMessage<'a> {
afk: bool,
status: &'a str,
since: SystemTime,
activities: &'a [&'a ActivityData],
activities: &'a [ActivityData],
}

#[derive(Serialize)]
Expand Down Expand Up @@ -231,8 +231,8 @@ impl WsClient {
intents: GatewayIntents,
presence: &PresenceData,
) -> Result<()> {
let activities: Vec<_> = presence.activity.iter().collect();
let now = SystemTime::now();
let activities = presence.activity.as_ref().map(std::slice::from_ref).unwrap_or_default();

debug!("[{:?}] Identifying", shard);

Expand All @@ -253,7 +253,7 @@ impl WsClient {
afk: false,
since: now,
status: presence.status.name(),
activities: &activities,
activities,
},
},
};
Expand All @@ -267,18 +267,18 @@ impl WsClient {
shard_info: &ShardInfo,
presence: &PresenceData,
) -> Result<()> {
let activities: Vec<_> = presence.activity.iter().collect();
let now = SystemTime::now();
let activities = presence.activity.as_ref().map(std::slice::from_ref).unwrap_or_default();

debug!("[{:?}] Sending presence update", shard_info);
debug!("[{shard_info:?}] Sending presence update");

self.send_json(&WebSocketMessage {
op: Opcode::PresenceUpdate,
d: WebSocketMessageData::PresenceUpdate(PresenceUpdateMessage {
afk: false,
since: now,
activities,
status: presence.status.name(),
activities: &activities,
}),
})
.await
Expand Down

0 comments on commit 90fbc11

Please sign in to comment.