Shrink Jim_Scope
size from 12 to 1 byte
#11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @rexim 👋
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 theJim
struct.