Small refactoring in replace

This commit is contained in:
Armin Ronacher 2021-02-01 13:26:03 +01:00
parent 1ae2f081b5
commit 8089e56f07

View file

@ -87,11 +87,9 @@ impl<D: DiffHook> DiffHook for Replace<D> {
old_len: usize,
new_index: usize,
) -> Result<(), D::Error> {
if let Some((a, b, c)) = self.eq.take() {
self.d.equal(a, b, c)?;
}
self.flush_eq()?;
if let Some((del_old_index, del_old_len, del_new_index)) = self.del.take() {
assert_eq!(old_index, del_old_index + del_old_len);
debug_assert_eq!(old_index, del_old_index + del_old_len);
self.del = Some((del_old_index, del_old_len + old_len, del_new_index));
} else {
self.del = Some((old_index, old_len, new_index));