smoltcp-rs / smoltcp

a smol tcp/ip stack
BSD Zero Clause License
3.64k stars 404 forks source link

Remove generic in parse and emit functions #879

Open thvdveld opened 6 months ago

thvdveld commented 6 months ago

I was using cargo bloat and I saw duplicate functions in wire. After this PR, the duplicates were gone. Removing the generics in the parse and emit functions prevents monomorphization of these functions. Preventing monomorphization reduces the binary size of the library.

cargo bloat --release --example server --filter smoltcp: On main: 216.3KiB On this branch: 202.5KiB

cargo bloat --release --example sixlowpan --filter smoltcp: On main: 213.9KiB On this branch: 199.0KiB

I know that this is for an example of std. However, the impact of code size will be smaller for embedded I suppose. The negative impact on user experience seems low since I didn't had to change much in the examples (only the ping example) and in the tests.

codecov[bot] commented 6 months ago

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (2e60fc2) 79.70% compared to head (36c89d0) 79.68%.

Files Patch % Lines
src/wire/ndiscoption.rs 50.00% 3 Missing :warning:
src/wire/arp.rs 66.66% 1 Missing :warning:
src/wire/ethernet.rs 0.00% 1 Missing :warning:
src/wire/icmpv4.rs 75.00% 1 Missing :warning:
src/wire/igmp.rs 50.00% 1 Missing :warning:
src/wire/ipv4.rs 75.00% 1 Missing :warning:
src/wire/udp.rs 83.33% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #879 +/- ## ========================================== - Coverage 79.70% 79.68% -0.03% ========================================== Files 78 78 Lines 28042 28002 -40 ========================================== - Hits 22351 22312 -39 + Misses 5691 5690 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.