tskit
tskit copied to clipboard
use restrict pointers in tsk_bit_array_* methods
The bit_array methods currently have pointer chasing like self->data within loops, which might reduce performance. It's worth declaring restrict pointers for these to help the compiler out.
void
tsk_bit_array_add(tsk_bit_array_t *self, const tsk_bit_array_t *other)
{
tsk_size_t i;
const tsk_size_t size = self->size;
tsk_bit_array_value_t * restrict self_data = self->data;
const tsk_bit_array_value_t * restrict other_data = other->data;
for (i = 0; i < size; i++) {
self_data[i] |= other_data[i];
}
}
I've made the size const as well here because the compiler might not (it probably would, but I'm not sure) know that this value is constant, and might decide to load the value from memory. Since this is perf sensitive, it's good to help the compiler out as much as possible.
Closing for inactivity and labelling "future", please re-open if you plan to work on this.
Reopening this as it's ongoing work