Thread

🛡️
i love unions in C. they allow you to pack different types of data into the same memory address. here's an example of an 64-bit string type that you can pass around as a native word on 64-bit systems. it can either be a binmoji or a 6-character null-terminated string. image this enabes the nostrdb metadata table to be super smol. caching reaction counts for any emoji or 6-length string can now be done inplace, only requiring two 64-bit integers worth of storage for each metadata entry, no string tables! image succinct, cache efficient data structures are my happy place

Replies (3)

Yes!! One of the first C things I did was make a dll to allow me to do all kinds of unholy reinterpretations of the same data in c#. I can't for the life of me remember why though. Probably something to do with wanting a single data column in a database that could be used by arbitrary types defined after the fact. The terrible sins I have committed trying to make a relational database that could handle future types without creating ad hoc tables or columns every time a product was added or changed.