3 ms·
FYI both kaoD and Kibwen's post seem to be dead because they included a link to a URL shortener (seems a little melodramatic on HNs part...) so I'll reproduce i
by nightpool 12y ago
FYI both kaoD and Kibwen's post seem to be dead because they included a link to a URL shortener (seems a little melodramatic on HNs part...) so I'll reproduce it here w/o the URL shortlink and see if that helps
>Hm, an enum like `enum Color { R, O, Y, G, B, I, V }` is represented by a u8 at runtime (see for yourself here[1]), which means that you're only saving a single byte in your `Piece` struct by doing that manual optimization. What was the magnitude of the speedup that you saw?
[1]: http://play.rust-lang.org/?code=%23%5Ballow(dead_code)%5D%0Aenum%20Color%20%7B%20R%2C%20O%2C%20Y%2C%20G%2C%20B%2C%20I%2C%20V%20%7D%0A%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20std%3A%3Amem%3A%3Asize_of%3A%3A%3CColor%3E())%3B%20%20%2F%2F%20size%20in%20bytes%0A%7D http://play.rust-lang.org/?code=%23%5Ballow(dead_code)%5D%0A...
- iamdanfox 12y agoAh that's good to know, looks like I should switch it back! The manual u8 stuff was pretty marginal. (It was also before I discovered the `PartialEq` and `Copy` traits, so please forgive my Rust inexperience!)