Refactor to add a is_empty_range function
This commit is contained in:
parent
c0e37a9c67
commit
1cc4ec4d25
3 changed files with 14 additions and 6 deletions
|
|
@ -7,6 +7,7 @@ use std::ops::{Index, Range};
|
|||
use std::time::Instant;
|
||||
|
||||
use crate::algorithms::DiffHook;
|
||||
use crate::utils::is_empty_range;
|
||||
|
||||
/// Hunt–McIlroy / Hunt–Szymanski LCS diff algorithm.
|
||||
///
|
||||
|
|
@ -52,10 +53,10 @@ where
|
|||
D: DiffHook,
|
||||
New::Output: PartialEq<Old::Output>,
|
||||
{
|
||||
if new_range.start >= new_range.end {
|
||||
if is_empty_range(&new_range) {
|
||||
d.delete(old_range.start, old_range.len(), new_range.start)?;
|
||||
return Ok(());
|
||||
} else if old_range.start >= old_range.end {
|
||||
} else if is_empty_range(&old_range) {
|
||||
d.insert(old_range.start, new_range.start, new_range.len())?;
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue