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’ll 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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jim.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ typedef enum {
} Jim_Scope_Kind;

typedef struct {
Jim_Scope_Kind kind;
int tail;
int key;
unsigned char kind : 6;
unsigned char tail : 1;
unsigned char key : 1;
} Jim_Scope;

typedef struct {
Expand Down
3 changes: 3 additions & 0 deletions test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#define JIM_IMPLEMENTATION
#include "./jim.h"
Expand Down Expand Up @@ -202,6 +203,8 @@ void test(void)

int main(int argc, char **argv)
{
assert(sizeof(Jim_Scope) == 1);

if (argc >= 2) {
if (strcmp(argv[1], "record") == 0) {
record("test_expected.h");
Expand Down