initialize some containers with_capacity

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-17 07:39:14 +00:00
parent b116984e46
commit 4343218957
2 changed files with 13 additions and 3 deletions

View file

@ -154,7 +154,7 @@ fn sign_request<T>(dest: &ServerName, http_request: &mut http::Request<Vec<u8>>)
where where
T: OutgoingRequest + Debug + Send, T: OutgoingRequest + Debug + Send,
{ {
let mut req_map = serde_json::Map::new(); let mut req_map = serde_json::Map::with_capacity(8);
if !http_request.body().is_empty() { if !http_request.body().is_empty() {
req_map.insert( req_map.insert(
"content".to_owned(), "content".to_owned(),

View file

@ -555,8 +555,18 @@ async fn send_events_dest_push(
async fn send_events_dest_normal( async fn send_events_dest_normal(
dest: &Destination, server: &OwnedServerName, events: Vec<SendingEvent>, dest: &Destination, server: &OwnedServerName, events: Vec<SendingEvent>,
) -> SendingResult { ) -> SendingResult {
let mut edu_jsons = Vec::new(); let mut pdu_jsons = Vec::with_capacity(
let mut pdu_jsons = Vec::new(); events
.iter()
.filter(|event| matches!(event, SendingEvent::Pdu(_)))
.count(),
);
let mut edu_jsons = Vec::with_capacity(
events
.iter()
.filter(|event| matches!(event, SendingEvent::Edu(_)))
.count(),
);
for event in &events { for event in &events {
match event { match event {