mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-02 02:59:51 +00:00
perf: optimize shrink frontiers
This commit is contained in:
parent
f4823191e7
commit
2b9194cf42
1 changed files with 5 additions and 5 deletions
|
@ -1031,6 +1031,11 @@ pub fn shrink_frontiers(last_ids: &[ID], dag: &AppDag) -> Result<Frontiers, ID>
|
|||
|
||||
let mut last_ids = {
|
||||
let ids = filter_duplicated_peer_id(last_ids);
|
||||
if last_ids.len() == 1 {
|
||||
frontiers.push(last_ids[0]);
|
||||
return Ok(frontiers);
|
||||
}
|
||||
|
||||
let mut last_ids = Vec::with_capacity(ids.len());
|
||||
for id in ids {
|
||||
let Some(lamport) = dag.get_lamport(&id) else {
|
||||
|
@ -1042,11 +1047,6 @@ pub fn shrink_frontiers(last_ids: &[ID], dag: &AppDag) -> Result<Frontiers, ID>
|
|||
last_ids
|
||||
};
|
||||
|
||||
if last_ids.len() == 1 {
|
||||
frontiers.push(last_ids[0].id());
|
||||
return Ok(frontiers);
|
||||
}
|
||||
|
||||
// Iterate from the greatest lamport to the smallest
|
||||
last_ids.sort_by_key(|x| x.lamport);
|
||||
for id in last_ids.iter().rev() {
|
||||
|
|
Loading…
Reference in a new issue