From 3ba8ad5f12268b8d95f115635d9dc9cfbd553513 Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Sun, 18 Aug 2024 15:07:56 +0800 Subject: [PATCH] fix: getting parent for root container error --- crates/loro-internal/src/arena.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/loro-internal/src/arena.rs b/crates/loro-internal/src/arena.rs index de951fcd..76601e76 100644 --- a/crates/loro-internal/src/arena.rs +++ b/crates/loro-internal/src/arena.rs @@ -216,6 +216,12 @@ impl SharedArena { } pub fn get_parent(&self, child: ContainerIdx) -> Option { + if self.get_container_id(child).unwrap().is_root() { + // TODO: PERF: we can speed this up by use a special bit in ContainerIdx to indicate + // whether the target is a root container + return None; + } + self.inner .parents .lock()