On every write operation, if a fragment is unique() and if it's parent fragment is unique() (i.e. it's not shared by other fragments) then merge the current fragment into parent. There is no overhead in doing that from amortized complexity perspective because that much complexity is already paid on making local changes.
Reference: https://www.reddit.com/r/cpp/comments/m9uwaq/releasing_lazy_map_c_library/grpj3gh?utm_source=share&utm_medium=web2x&context=3
On every write operation, if a fragment is unique() and if it's parent fragment is unique() (i.e. it's not shared by other fragments) then merge the current fragment into parent. There is no overhead in doing that from amortized complexity perspective because that much complexity is already paid on making local changes.
Reference: https://www.reddit.com/r/cpp/comments/m9uwaq/releasing_lazy_map_c_library/grpj3gh?utm_source=share&utm_medium=web2x&context=3