]> diplodocus.org Git - nmh/commit
sbr/vector.c: Embed initial vector storage in header struct.
authorRalph Corderoy <ralph@inputplus.co.uk>
Tue, 25 Apr 2017 22:21:21 +0000 (23:21 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Wed, 26 Apr 2017 06:43:41 +0000 (07:43 +0100)
commit67733cd0356ecf398135fc3f2978aabcd6900783
treedbb492d4e26bea9fd148f0e7a38b0fca4d08553f
parent5fa3d9aa99f952d8ca032f94f9c47b739e2ef7e7
sbr/vector.c: Embed initial vector storage in header struct.

Instead of a malloc(3)'d struct bvector having a pointer to a separately
malloc'd area for the bits in the normal case of the default initial
size, have non-malloc'd storage in the struct itself, and set the
pointer to that.  It's two unsigned longs, which is less than the
previous default of 256 bits for struct bvector, but still double the
pre-bvector norm of one word on 32 and 64-bit architectures.

This halves the mallocs needed to create a struct bvector in the common
case, but does mean that embedded memory is wasted should it not be
enough.  That's probably an unusual case.  It also means derefencing the
pointer to the bits probably hits the same cache line.

Have separate initial sizes for string and int vectors.
sbr/vector.c