3 ms·
No, the time isn't really what I'm referring to—ip addressing is complicated. But it shouldn't require having to work around the language to do this kind of thi
by nynx 6y ago
No, the time isn't really what I'm referring to—ip addressing is complicated. But it shouldn't require having to work around the language to do this kind of thing.
- tick_tock_tick 6y agoI'm not sure how this is a "work around the language" rather then the standard library in Golang is allocation happy for IP types. I imagine this would look very similar in almost any language.
- nynx 6y agoFor example, look at rust's [0]. It claims to vary in size depending on os, but on Linux, at least, it's 20 bytes. [0]: https://doc.rust-lang.org/std/net/enum.IpAddr.html https://doc.rust-lang.org/std/net/enum.IpAddr.html
- tick_tock_tick 6y agoThis type doesn't appear to support IPv6 Address Zones which was the most complicated part of the post. Actually from my limited googling Rust doesn't seem to support Address Zones at all in it's standard library.
- nynx 6y agoThat's a good point.
- zeeboo 6y agoIt also doesn't include the ipv6 zone scope. Adding that would take it to at least 28 bytes, and still have to handle all the interning problems for cheap equality.
- nonameiguess 6y agoAppears to be 16 bytes on Windows (larger of the two variants): https://github.com/rust-lang/rust/blob/master/library/std/src/sys/windows/c.rs#L598 https://github.com/rust-lang/rust/blob/master/library/std/sr...
- Dylan16807 6y agoThe entire section about comparisons and string interning is extremely "work around the language".
- tick_tock_tick 6y agoInterning is to reduce memory usage. I will agree the uintptr trick is a work around for the lack of weak refs in golang but the code isn't that different then what you would write if you have a referenced counted cache.