mirror of
https://github.com/apple/swift-collections
synced 2026-11-22 04:20:40 +00:00
A rope may contain the same leaf node at multiple positions (e.g. after appending a rope to itself, or inserting a BigString slice into its own base). Rope.distance(from:to:in:) assumed that two indices with the same cached leaf reference address the same position in the tree, and returned a distance computed only from their leaf slots. Also compare the paths above the leaf level before taking the fast path. This made BigString's character/scalar/UTF-16 distances and index(_:offsetBy:) return wrong results (including indices with a bogus utf8Offset) after such operations.