mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Speed up anchor comparison when the version is the same
This commit is contained in:
parent
11a3b8c5ce
commit
84fe7f50ac
1 changed files with 17 additions and 6 deletions
|
@ -61,15 +61,26 @@ impl Anchor {
|
||||||
(Anchor::End, _) | (_, Anchor::Start) => Ordering::Greater,
|
(Anchor::End, _) | (_, Anchor::Start) => Ordering::Greater,
|
||||||
(
|
(
|
||||||
Anchor::Middle {
|
Anchor::Middle {
|
||||||
bias: self_bias, ..
|
offset: self_offset,
|
||||||
|
bias: self_bias,
|
||||||
|
version: self_version,
|
||||||
},
|
},
|
||||||
Anchor::Middle {
|
Anchor::Middle {
|
||||||
bias: other_bias, ..
|
offset: other_offset,
|
||||||
|
bias: other_bias,
|
||||||
|
version: other_version,
|
||||||
},
|
},
|
||||||
) => buffer
|
) => {
|
||||||
.full_offset_for_anchor(self)
|
let offset_comparison = if self_version == other_version {
|
||||||
.cmp(&buffer.full_offset_for_anchor(other))
|
self_offset.cmp(other_offset)
|
||||||
.then_with(|| self_bias.cmp(&other_bias)),
|
} else {
|
||||||
|
buffer
|
||||||
|
.full_offset_for_anchor(self)
|
||||||
|
.cmp(&buffer.full_offset_for_anchor(other))
|
||||||
|
};
|
||||||
|
|
||||||
|
offset_comparison.then_with(|| self_bias.cmp(&other_bias))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue