These functions are the most logic heavy parts of the codebase. They currently don't resemble each other much at all.
Mutate traverses and rebuilds the buckets by level. Diff traverses and looks for changes by key, looking at buckets of all levels at once. This results in a different yielded order of buckets as well. Mutate yields changed buckets in order of level first, and diff yields them in order of the last entries key.
The idea to combine the logic and have them yield buckets in the same order is to change mutate so that it rebuilds buckets at multiple levels. Instead of rebuilding the whole lower levels first, rebuild and yield buckets on lower or higher levels as boundaries are created.
These functions are the most logic heavy parts of the codebase. They currently don't resemble each other much at all.
Mutate traverses and rebuilds the buckets by level. Diff traverses and looks for changes by key, looking at buckets of all levels at once. This results in a different yielded order of buckets as well. Mutate yields changed buckets in order of level first, and diff yields them in order of the last entries key.
The idea to combine the logic and have them yield buckets in the same order is to change mutate so that it rebuilds buckets at multiple levels. Instead of rebuilding the whole lower levels first, rebuild and yield buckets on lower or higher levels as boundaries are created.