Re:Rust: 128 bit integers preparing to be released
by dbaupp on Sunday December 04, 2016 @01:25AM
(#13099020)
I don't see the obvious problem (fwiw, I really dislike such rhetorical devices): presumably net.IP could a struct that contains a [16]byte and an isV4 flag.
[ Parent
| on HN ]
Re:Rust: 128 bit integers preparing to be released
by barsonme on Sunday December 04, 2016 @02:24AM
(#13099151)
The problem is [16]byte would always be wasting 12 bytes for IPv4 addresses if you only used one type for both. So, two types must be made which requires extra code and doesn't allow for == comparison which is what OP (GP? whomever...) was complaining about not being able to do since net.IP is []byte.
Sorry for the rhetorical device.
Re:Rust: 128 bit integers preparing to be released
by ben0x539 on Sunday December 04, 2016 @03:50AM
(#13099319)
Isn't the indirection overhead of a []byte more expensive than a spare 12 inline bytes?
Re:Rust: 128 bit integers preparing to be released
by dbaupp on Sunday December 04, 2016 @12:04PM
(#13100618)
Yes, and a []byte is even going to have at least as much inline overhead: it stores 24 bytes (length, capacity, pointer), and of course plus the 4 bytes of actual data. Even on a 32-bit platform, the []byte inline storage is 12 bytes.