Joe Buck wrote:
As a general rule there is a performance cost for making iterators
on a data structure safe with respect to modifications of that data
structure.
Absolutely true.
I'm not in a position to say what the right solution is
in this case, but passes that iterate over bitmaps without modifying
those bitmaps shouldn't be penalized.  One solution sometimes used is
two sets of iterators, with a slower version that's safe under
modification.
I wasn't suggesting we make them "safe" in the sense that one could modify the bitmap and everything would just work. Instead I was suggesting we make the bitmap readonly for the duration of the iterator and catch attempts to modify the bitmap -- under the control of ENABLE_CHECKING of course. If that turns out to still be too expensive, it could be conditional on ENABLE_BITMAP_ITERATOR_CHECKING or whatever, which would normally be off.

My biggest concern would be catching all the exit paths from the gazillion iterators we use and making sure they all reset the readonly flag. Ick...


jeff

Reply via email to