]> git.eshelyaron.com Git - emacs.git/commit
itree: Use a single iterator object
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 2 Oct 2022 16:27:37 +0000 (12:27 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 2 Oct 2022 16:27:37 +0000 (12:27 -0400)
commit2c4a3910b384a1f5b14d282818b04e25785e25b0
tree751f2057dba9d2dfb42ef5b8902a7e99054c8d71
parentb8fbd42f0a7caa4cd9e2d50dd4e4b2101ac78acd
itree: Use a single iterator object

Instead of having one iterator object per buffer, use just a single
global one.  There is virtually no benefit to having per-buffer
iterators anyway: if two iterations can be active at the same time,
then there can be cases where those two iterations happen
to operate on the same buffer :-(

* src/itree.h (struct interval_tree): Remove `iter` field.
* src/itree.c (interval_generator_destroy)
(interval_tree_iter_ensure_space): Delete functions.
(iter): New global variable.
(init_itree_null): Rename to `itree_init` and adjust all callers.
Initialize `iter` as well.
(interval_tree_create, interval_tree_init):
Don't initialize `iter` field any more.
(interval_tree_destroy): Don't destroy `iter` field any more.
(interval_tree_insert): Don't bother growing the iterator (it's grown
in `interval_stack_push_flagged` if needed anyway, and in any case
there's no `iter` here to grow any more).
(interval_tree_remove): Tweak assertion to be more precise and
self-evident.
(interval_tree_iter_start): Use the global `iter`.
(interval_generator_create): Make it work with a NULL argument.
src/itree.c
src/itree.h