diff --git a/CHANGELOG.md b/CHANGELOG.md index cb956cf55..121fe6817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ Fixed an issue where files with no common content would show duplicate hunks. +Fixed a performance issue when files had extremely long lines +(e.g. 100,000+ characters). + ## 0.59 (released 20th July 2024) ### Diffing diff --git a/src/line_parser.rs b/src/line_parser.rs index 208652916..f2ed5cd33 100644 --- a/src/line_parser.rs +++ b/src/line_parser.rs @@ -278,8 +278,9 @@ mod tests { // Even though the word exists on both sides, it should still // be treated as a change. We're doing a line-based diff and // the lines are different. - let positions = change_positions("foo", " foo"); - assert!(positions[0].kind.is_novel()); + let mut positions = change_positions("foo", " foo"); + let last_pos = positions.pop().unwrap(); + assert!(last_pos.kind.is_novel()); } #[test] @@ -300,17 +301,17 @@ mod tests { #[test] fn test_novel_lhs_trailing_newlines() { - let positions = change_positions("foo\n", ""); + let mut positions = change_positions("foo\n", ""); - assert_eq!(positions.len(), 2); - assert!(positions[0].kind.is_novel()); + let last_pos = positions.pop().unwrap(); + assert!(last_pos.kind.is_novel()); } #[test] fn test_positions_novel_lhs() { - let positions = change_positions("foo", ""); + let mut positions = change_positions("foo", ""); - assert_eq!(positions.len(), 1); - assert!(positions[0].kind.is_novel()); + let last_pos = positions.pop().unwrap(); + assert!(last_pos.kind.is_novel()); } }