(start: UUID)
| 2012 | // compression: after resolving, seed the map with the resolved link so |
| 2013 | // subsequent survivors sharing the same chain segment don't re-walk. |
| 2014 | const resolve = (start: UUID): UUID | null => { |
| 2015 | const path: UUID[] = [] |
| 2016 | let cur: UUID | null | undefined = start |
| 2017 | while (cur && toDelete.has(cur)) { |
| 2018 | path.push(cur) |
| 2019 | cur = deletedParent.get(cur) |
| 2020 | if (cur === undefined) { |
| 2021 | cur = null |
| 2022 | break |
| 2023 | } |
| 2024 | } |
| 2025 | for (const p of path) deletedParent.set(p, cur) |
| 2026 | return cur |
| 2027 | } |
| 2028 | let relinkedCount = 0 |
| 2029 | for (const [uuid, msg] of messages) { |
| 2030 | if (!msg.parentUuid || !toDelete.has(msg.parentUuid)) continue |
no test coverage detected