I believe there are cases where using &root directly, rather than doing var r = root; b.push(&r, slicedBy: range) might modify root after the first push so that the second push(_:slicedBy:) won't work correctly.
But I'm inconsistent (sometimes I create a second reference, sometimes I don't), and I'm not sure which is correct.
I need to audit BTreeBuilder, as well as all the call sites to push(:slicedBy:) and push(:) to make sure I understand what's going on. I also need to write tests to verify the correct behavior.
This pattern is common enough that it might be beneficial to define a method to do this in an extension to BTree.
There are a bunch of places where I have the following pattern:
I believe there are cases where using
&root
directly, rather than doingvar r = root; b.push(&r, slicedBy: range)
might modify root after the first push so that the secondpush(_:slicedBy:)
won't work correctly.But I'm inconsistent (sometimes I create a second reference, sometimes I don't), and I'm not sure which is correct.
I need to audit BTreeBuilder, as well as all the call sites to push(:slicedBy:) and push(:) to make sure I understand what's going on. I also need to write tests to verify the correct behavior.
This pattern is common enough that it might be beneficial to define a method to do this in an extension to BTree.