From ba57606fdbf68fc166b85be51a02d391888bd10b Mon Sep 17 00:00:00 2001 From: jrx Date: Fri, 29 Nov 2024 23:55:26 +0100 Subject: [PATCH] avoid string reallocation --- src/decoders/dns.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/decoders/dns.rs b/src/decoders/dns.rs index aa8ecd3..35d70f6 100644 --- a/src/decoders/dns.rs +++ b/src/decoders/dns.rs @@ -255,13 +255,13 @@ fn parse_svcb_ip(mut input: &[u8]) -> nom::IResult<&[u8], String> { if ip_version == IPV4 { let mut iter = iterator(ip_data, ipv4_parser); for ip in iter.into_iter() { - ipv4_hint = format!("{}{},", ipv4_hint, ip); + write!(ipv4_hint, "{},", ip).ok(); // ignore errors on write in String } iter.finish()?; } else if ip_version == IPV6 { let mut iter = iterator(ip_data, ipv6_parser); for ip in iter.into_iter() { - ipv6_hint = format!("{}{},", ipv6_hint, ip); + write!(ipv6_hint, "{},", ip).ok(); // ignore errors on write in String } iter.finish()?; }