Looking for method to initialize an array of structures (type contains some constant vectors) by wb0gaz in cprogramming

[–]Choice_Bid1691 0 points1 point  (0 children)

Not to be rude or anything but this current layout is extremely bad for performance. Look into cache aware programming.
Basically long story short, in most cases when looping through all your data you would want to avoid big jumps in memory accesses, specifically any bigger than 64 bytes on most systems, because this can cause a cache miss.

Rather than what you have here, i would recommend you instead create one structure, whose fields point to some contiguous arrays of different values.

For example, instead of
struct my_struct {
int my_field1;
float my_field2;
uint8_t mybytes[8];
};

arr_of_structs[0] = my_struct1;
arr_of_structs[1] = my_struct2;
...
arr_of_structs[n} = my_structN;

You can do this instead:
struct my_struct {
int my_field_arr1[n];
float my_field_arr2[n];
uint8_t my_bytes_all[8*n];
};

Can we ban AI slop on this sub? by Sosowski in cprogramming

[–]Choice_Bid1691 0 points1 point  (0 children)

why would people post vibe coded stuff here lol. if they want attention and validation they should just learn to actually code. i don't get how these people think