Vector* vector_create(size_t itemSize) {
Vector* vec = (Vector*)malloc(sizeof(Vector));
// ...
return vec;
}
This just immediately strike me as poor code. void vector_init(Vector *v, size_t itemSize) {
v->itemSize = itemSize;
// ...
}
Instantly cleaner, more efficient, less memory allocation/handling needed, lets the user control where the Vector is stored. #push_optimize(assume_no_integer_overflow)
int x = a + b;
// more performance orientated code
#pop_optimize
// back to sane C
#push_optimize(assume_no_alias(a, b), assume_stride(a, 16), assume_stride(b, 16))
void compute(float *a, float *b, int index)
{
// here the compiler can assume a and b do not alias
// and it can assume it can always load 16 bytes at a time
// the programmer has made sure it's aligned and padded to so with any index
// there's always 16 bytes to load
// so go on, use any vectorized simd instruction you want
}
#pop_optimize
// back to sane C
Politicians only starts caring about peoples problems if they are either personally effected or one of their close friends/benefactors are effected.