this post was submitted on 15 May 2025
1148 points (98.6% liked)

Programmer Humor

23417 readers
1494 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] kiri@ani.social 21 points 1 week ago* (last edited 1 week ago) (1 children)

I have a solution with a bit fields. Now your bool is 1 byte :

struct Flags {
    bool flag0 : 1;
    bool flag1 : 1;
    bool flag2 : 1;
    bool flag3 : 1;
    bool flag4 : 1;
    bool flag5 : 1;
    bool flag6 : 1;
    bool flag7 : 1;
};

Or for example:

struct Flags {
    bool flag0 : 1;
    bool flag1 : 1:
    int x_cord : 3;
    int y_cord : 3;
};
[โ€“] lapping6596@lemmy.world 3 points 1 week ago

I watched a YouTube video where a dev was optimizing unity code to match the size of data that is sent to the cpu using structs just like this.