From c2f4b1f2ee5a6dbf1ac32c0451878cf488493809 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sun, 21 Jul 2024 11:15:54 -0700 Subject: [PATCH] Update tests and changelog for 1e8be4558b --- CHANGELOG.md | 3 +++ src/line_parser.rs | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) 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()); } }