diff options
author | rockcavera <rockcavera@gmail.com> | 2022-12-30 05:20:32 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-30 09:20:32 +0100 |
commit | e5639408d55c3b9164790bee37580a74a15b666f (patch) | |
tree | 78d66ea1c8dcd5b2b395b1daebf4ab005b6b39c8 /readme.md | |
parent | c598d0b6eccd3133bfca710fc5fcc4576501862c (diff) | |
download | Nim-e5639408d55c3b9164790bee37580a74a15b666f.tar.gz |
avoiding unnecessary allocation for dollar IpAddress (#21199)
* avoiding allocating an unnecessary byte for IPv4 The inet.h file uses 16 as the string in C needs the last null byte https://github.com/torvalds/linux/blob/1b929c02afd37871d5afb9d498426f83432e71c2/include/linux/inet.h#L49 However, strings in Nim do not need this. So one byte is being allocated unnecessary and will never be used. * avoid unnecessary allocation in IPv6 dollar It is currently allocating 48 bytes. However, the Nim implementation for IPv6 will print a maximum of 39 characters. Nim does not implement IPv6 "0000:0000:0000:0000:0000:ffff:255.255.255.255" (45 characters) nor "0000:0000:0000:0000:0000:ffff:255.255.255.255%3" (47 characters). The indication in inet.h for 48 is due to the maximum use of 47 characters of a C string that needs a null byte at the end. So 48. https://github.com/torvalds/linux/blob/1b929c02afd37871d5afb9d498426f83432e71c2/include/linux/inet.h#L50
Diffstat (limited to 'readme.md')
0 files changed, 0 insertions, 0 deletions