WIP: Compare anchors without using FragmentId

This commit is contained in:
Antonio Scandurra
2021-06-01 17:54:58 +02:00
parent b3f13ce325
commit df13cf0a90
2 changed files with 49 additions and 9 deletions
+15 -9
View File
@@ -63,21 +63,27 @@ impl Anchor {
Anchor::Middle {
offset: self_offset,
bias: self_bias,
version: self_version,
..
},
Anchor::Middle {
offset: other_offset,
bias: other_bias,
version: other_version,
..
},
) => {
let offset_comparison = if self_version == other_version {
self_offset.cmp(other_offset)
} else {
self.to_offset(buffer).cmp(&other.to_offset(buffer))
};
offset_comparison.then_with(|| self_bias.cmp(other_bias))
dbg!(
self,
other,
self_offset,
other_offset,
buffer.fragment_ix_for_anchor(self),
buffer.fragment_ix_for_anchor(other)
);
buffer
.fragment_ix_for_anchor(self)
.cmp(&buffer.fragment_ix_for_anchor(other))
.then_with(|| self_offset.cmp(&other_offset))
.then_with(|| self_bias.cmp(other_bias))
}
})
}