Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shrink Jim_Scope size from 12 to 1 byte #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HalidOdat
Copy link

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 ints 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.

We store the `Jim_Scope` as a bit field. We keep 6 bits for the kind
(enough to store 64 different kinds), 1 bit for the tail and another 1
bit for key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant