bitv_t bits[2]; in include/bu/bitv.h is giving me grief with the -Werror=stringop-overflow= error again. Multiple AI sessions indicate the right fix is to use a C99 variable array here... @Sean is there any reason not to go ahead and make that shift at this point, since we require that standard anyway?
Never mind, I see C++ doesn't like it
I was going to say, that trick is squarely in low-level C territory that doesn't have a migration equivalent. My gut reaction is to set up performance harness around it as it's a critical ray tracing book-keeping structure, but then work to replace it with a C++ construct under the hood as an opaque type. It'll be hard to get it right, i.e., without screwing performance either on reads or writes.
I'm setting up some more test harnessing to benchmark it, and have a refactoring in progress.
okay, I think I'm done -- short summary is bu_bitv is surprisingly about as fast as I could get it to go.
switching it to a 64bit type fixes the alignment and either that or the fact that it's no longer a 2-element array seems to avoid triggering the compiler warning. I added api to do callback iteration instead of macro hacking, and a few more missing funcs.
also ran through a slew of performance testing, both before and after as well as against STL vector<bool>. summary is we should probably continue to leave it alone... bu_bitv absolutely crushes it on boolean ops and set/testing on sparse bitsets, and is otherwise equivalent on bit set/test and clearing. room for improvement in deserialize/serialize calls.
morrison@Miniagua brlcad.main % ./a.out
=============================================================
BRL-CAD bu_bitv vs STL std::vector<bool> benchmark
=============================================================
Vector size : 100000000 bits
Iterations : 10
Ops total : ~1000000000 per test
Operation bu_bitv (us) vector<bool> (us) ratio winner
-------------------------------- ------------ ----------------- ---------- -------------
ratio = stl_time / bitv_time: >1.0 => bu_bitv faster, <1.0 => STL faster
new/free 5953 2308 0.39x STL wins
BU_BITSET / v[i]=1 3460549 3468407 1.00x bu_bitv wins
BU_BITTEST / v[i] 643232 643769 1.00x bu_bitv wins
BU_BITCLR / v[i]=0 3463984 3463004 1.00x STL wins
bu_bitv_clear / assign(0) 1974 1576 0.80x STL wins
bu_bitv_or / stl_or 7959 4833792 607.34x bu_bitv wins
BU_BITS2WORDS / bits2words() 206027 379963 1.84x bu_bitv wins
bu_bitv_dup / copy-ctor 12086 3300 0.27x STL wins
bu_bitv_to_hex / stl_to_hex 155474 9750651 62.72x bu_bitv wins
bu_bitv_vls / stl_vls 18281 929630 50.85x bu_bitv wins
Aggregate totals across all tests:
bu_bitv total: 7975519 us
vector<bool> total: 23476400 us
overall ratio: 2.94x
Last updated: Jun 06 2026 at 02:08 UTC