jim
jim copied to clipboard
Shrink `Jim_Scope` size from 12 to 1 byte
Hi @rexim :wave:
I came across this library while I was watching your youtube video on implementing GC in C (awesome video btw). And thought I'd check it out :)
While checking the code I found that we keep the scopes as three int
s one for kind, one for tail and one for key. The size of this is 12 bytes. But we can store it as bit field. And keep 6 bits for the kind (enough to store 64 different kinds, we only have 2 now), 1 bit for the tail and another 1 bit for key (since key and tail can only be 1 or 0 we only need 1 bit). With this we save 11 bytes per scope. And since we have 128 by default, that's 1408 less bytes for the Jim
struct.