servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.27k stars 317 forks source link

perf: Use `NonZeroU16` for port numbers #930

Open DonIsaac opened 1 month ago

DonIsaac commented 1 month ago

Changing URL's port field from Option<u16> to Option<NonZeroU16> would enable some memory layout optimizations, allowing port to have the same size as u16. Trying this out locally results in a 10% smaller memory footprint for Url (88 bytes -> 80 bytes).