From 31e30d4aa17e48ede2156651bf586e2e6b99ceb7 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Mon, 28 Apr 2025 10:44:09 +0200 Subject: [PATCH] sdp: use rust join It is much faster as it does not do an allocation for each element --- rust/src/sdp/parser.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/src/sdp/parser.rs b/rust/src/sdp/parser.rs index 3ab9d932ca..105bc51f6c 100644 --- a/rust/src/sdp/parser.rs +++ b/rust/src/sdp/parser.rs @@ -464,9 +464,9 @@ fn parse_media_description(i: &[u8]) -> IResult<&[u8], MediaDescription> { format!("{}", port) }; let mut media_str = format!("{} {} {}", &media, &port, &proto); - let fmt: Vec = fmt.into_iter().map(String::from).collect(); - for f in &fmt { - media_str = format!("{} {}", media_str, f); + if !fmt.is_empty() { + let fmt: Vec = fmt.into_iter().map(String::from).collect(); + media_str = format!("{} {}", media_str, fmt.join(" ")); } Ok(( i, -- 2.47.2