mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-22 12:57:20 +00:00
refactor: refine parent info register
This commit is contained in:
parent
a7816af173
commit
24583ba33a
4 changed files with 8 additions and 10 deletions
|
@ -222,7 +222,7 @@ impl SharedArena {
|
|||
.unwrap()
|
||||
.get(&child)
|
||||
.copied()
|
||||
.flatten()
|
||||
.expect("InternalError: Parent is not registered")
|
||||
}
|
||||
|
||||
/// Call `f` on each ancestor of `container`, including `container` itself.
|
||||
|
@ -234,7 +234,7 @@ impl SharedArena {
|
|||
while let Some(c) = container {
|
||||
f(c, is_first);
|
||||
is_first = false;
|
||||
container = self.get_parent(c);
|
||||
container = self.get_parent(c)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,12 @@ pub mod idx {
|
|||
///
|
||||
/// TODO: make this type private in this crate only
|
||||
///
|
||||
///
|
||||
// During a transaction, we may create some containers which are deleted later. And these containers also need a unique ContainerIdx.
|
||||
// So when we encode snapshot, we need to sort the containers by ContainerIdx and change the `container` of ops to the index of containers.
|
||||
// An empty store decodes the snapshot, it will create these containers in a sequence of natural numbers so that containers and ops can correspond one-to-one
|
||||
//
|
||||
// TODO: PERF: use NonZeroU32 to save memory
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
|
||||
pub struct ContainerIdx(u32);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ mod iter;
|
|||
pub(crate) mod loro_dag;
|
||||
mod pending_changes;
|
||||
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::Ordering;
|
||||
|
@ -21,13 +20,13 @@ use crate::encoding::{decode_oplog, encode_oplog, EncodeMode};
|
|||
use crate::history_cache::ContainerHistoryCache;
|
||||
use crate::id::{Counter, PeerID, ID};
|
||||
use crate::op::{FutureInnerContent, ListSlice, RawOpContent, RemoteOp, RichOp};
|
||||
use crate::span::{HasCounterSpan, HasIdSpan, HasLamportSpan};
|
||||
use crate::span::{HasCounterSpan, HasLamportSpan};
|
||||
use crate::version::{Frontiers, VersionVector};
|
||||
use crate::LoroError;
|
||||
use change_store::BlockOpRef;
|
||||
pub use change_store::{BlockChangeRef, ChangeStore};
|
||||
use loro_common::{HasId, IdLp, IdSpan};
|
||||
use rle::{HasLength, Mergable, RleVec, Sliceable};
|
||||
use loro_common::{IdLp, IdSpan};
|
||||
use rle::{HasLength, RleVec, Sliceable};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use self::iter::MergedChangeIter;
|
||||
|
|
|
@ -892,10 +892,6 @@ impl DocState {
|
|||
F: FnOnce(&State) -> R,
|
||||
{
|
||||
let depth = self.arena.get_depth(idx).unwrap().get() as usize;
|
||||
let parent = self
|
||||
.arena
|
||||
.get_parent(idx)
|
||||
.and_then(|a| self.arena.get_container_id(a));
|
||||
let state = self
|
||||
.store
|
||||
.get_or_create(idx, || {
|
||||
|
|
Loading…
Reference in a new issue