Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah, tricks like that are still done for maximum speed for things like fitting as much data into structs/classes.

Like assuming (or enforcing) items are allocated to 4-byte memory boundary addresses, so that you can mask the first two bits of a pointer and use it for storing flags.

Similarly, you can pre-allocate tree nodes (left and right children) in a continuous array, and then only store a single pointer to the left node, and the right node will be the address of the left node + 1, so you save 8-bytes in the struct/class.

This allows more items into the processor cache line.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: