mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-22 21:07:43 +00:00
refactor: rm has_dependents field in change
It's not longer required
This commit is contained in:
parent
338601308e
commit
1f3290ef80
6 changed files with 10 additions and 17 deletions
|
@ -35,8 +35,6 @@ pub struct Change<O = Op> {
|
|||
/// [Unix time](https://en.wikipedia.org/wiki/Unix_time)
|
||||
/// It is the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970.
|
||||
pub(crate) timestamp: Timestamp,
|
||||
/// if it has dependents, it cannot merge with new changes
|
||||
pub(crate) has_dependents: bool,
|
||||
}
|
||||
|
||||
impl<O> Change<O> {
|
||||
|
@ -53,7 +51,6 @@ impl<O> Change<O> {
|
|||
id,
|
||||
lamport,
|
||||
timestamp,
|
||||
has_dependents: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +205,6 @@ impl<O: Mergable + HasLength + HasIndex + Sliceable + HasCounter + Debug> Slicea
|
|||
id: self.id.inc(from as Counter),
|
||||
lamport: self.lamport + from as Lamport,
|
||||
timestamp: self.timestamp,
|
||||
has_dependents: self.has_dependents,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,6 @@ fn decode_changes<'a>(
|
|||
deps: Frontiers::with_capacity((deps_len + if dep_on_self { 1 } else { 0 }) as usize),
|
||||
lamport: 0,
|
||||
timestamp,
|
||||
has_dependents: false,
|
||||
};
|
||||
|
||||
if dep_on_self {
|
||||
|
|
|
@ -262,10 +262,7 @@ impl OpLog {
|
|||
|
||||
let timestamp_change = change.timestamp - last.timestamp;
|
||||
// TODO: make this a config
|
||||
if !last.has_dependents
|
||||
&& change.deps_on_self()
|
||||
&& timestamp_change < merge_interval
|
||||
{
|
||||
if change.deps_on_self() && timestamp_change < merge_interval {
|
||||
for op in take(change.ops.vec_mut()) {
|
||||
last.ops.push(op);
|
||||
}
|
||||
|
@ -379,11 +376,7 @@ impl OpLog {
|
|||
fn ensure_dep_on_change_end(&mut self, src: PeerID, dep: ID) {
|
||||
let changes = self.changes.get_mut(&dep.peer).unwrap();
|
||||
match changes.binary_search_by(|c| c.ctr_last().cmp(&dep.counter)) {
|
||||
Ok(index) => {
|
||||
if src != dep.peer {
|
||||
changes[index].has_dependents = true;
|
||||
}
|
||||
}
|
||||
Ok(_) => {}
|
||||
Err(index) => {
|
||||
// This operation is slow in some rare cases, but I guess it's fine for now.
|
||||
//
|
||||
|
@ -565,7 +558,6 @@ impl OpLog {
|
|||
deps: change.deps.clone(),
|
||||
lamport: change.lamport,
|
||||
timestamp: change.timestamp,
|
||||
has_dependents: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -542,7 +542,6 @@ pub fn decode_block(
|
|||
id: ID::new(header.peer, header.counters[i]),
|
||||
lamport: header.lamports[i],
|
||||
timestamp: timestamp_decoder.next().unwrap().unwrap() as Timestamp,
|
||||
has_dependents: true, // FIXME: this field
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -315,7 +315,6 @@ impl Transaction {
|
|||
self.timestamp
|
||||
.unwrap_or_else(|| oplog.get_timestamp_for_next_txn()),
|
||||
),
|
||||
has_dependents: false,
|
||||
};
|
||||
|
||||
let diff = if state.is_recording() {
|
||||
|
|
|
@ -27,5 +27,13 @@
|
|||
"https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/separator.ts": "9dd15d46ff84a16e13554f56af7fee1f85f8d0f379efbbe60ac066a60561f036",
|
||||
"https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/win32.ts": "47114c941681ecbabab4ec355cb41d525fb5a14175cc47a5c76fdc5eaee2685a",
|
||||
"https://raw.githubusercontent.com/zxch3n/dirname/master/mod.ts": "79768be98329cc670a80bd4f5ce9800412944aba27f563a6314ae2c4589be229"
|
||||
},
|
||||
"workspace": {
|
||||
"packageJson": {
|
||||
"dependencies": [
|
||||
"npm:vite-plugin-top-level-await@^1.2.2",
|
||||
"npm:vite-plugin-wasm@^3.1.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue