
31 Dec
2008
31 Dec
'08
8:51 p.m.
Denis Gabaidulin wrote:
Key never change, but value can.
so why store the key? eg const char * keytable[] { "key1", // store keys at compile time in order "key2", ... } unsigned int values [sizeof(keytable) / sizeof(const char *)]; unsigned int get_key_index(const char * k){ // look up key with binary search } Then just serialize the values array. My real point is that if you find yourself wanting to serialze a const value, your likely missing out on making a much faster implementation. Any time you feel the need to change a "const" value it's a red flag that something can be done better. Robert Ramey