|
|
|
|
|
by trishume
3644 days ago
|
|
Except that LuaJIT does something close to just a pointer offset. The trick it uses is to use a hash function that is known by the compiler so when you have a constant key ("y" in this case) the hash table set is compiled down to 3 instructions (imagine hash("y") = 0xa7): 1. Load whatever necessary to check if x[0xa7] is occupied
2. Branch to slow path if occupied
3. Store x[0xa7] = 'z' And a modern super-scalar CPU will even do some of this in parallel. |
|