Merge pull request #1232 from LeandroPG19/perf/presize-mac-string
Some checks failed
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled

perf: pre-size mac_from_dec_to_hex String with capacity
This commit is contained in:
Giuliano Bellini 2026-07-13 23:29:52 +02:00 committed by GitHub
commit 7622d415ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -492,7 +492,7 @@ pub fn is_my_address(local_address: &IpAddr, my_interface_addresses: &Vec<Addres
/// Converts a MAC address in its hexadecimal form
fn mac_from_dec_to_hex(mac_dec: [u8; 6]) -> String {
let mut mac_hex = String::new();
let mut mac_hex = String::with_capacity(17);
for n in &mac_dec {
let _ = write!(mac_hex, "{n:02x}:");
}