File: consecutive-words.diff

package info (click to toggle)
rust-riffdiff 3.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 5,784 kB
  • sloc: sh: 206; python: 132; makefile: 11
file content (41 lines) | stat: -rw-r--r-- 1,481 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
commit bbc4309d726819512f9b5fb72b187eeb63d34680
Author: Johan Walles <johan.walles@gmail.com>
Date:   Thu Dec 31 15:22:09 2020 +0100

    Skip highlighting based on newline counts

    If old text and new text have very different line counts, just do the
    simplistic highlighting.

diff --git xsrc/refiner.rs xsrc/refiner.rs
index d1ebdc1..40ae0df 100644
--- xsrc/refiner.rs
+++ xsrc/refiner.rs
@@ -15,8 +15,8 @@ use diffus::{
 /// it.
 const MAX_HIGHLIGHT_PERCENTAGE: usize = 30;

-const LARGE_BYTE_COUNT_CHANGE_PERCENT: usize = 100;
-const SMALL_BYTE_COUNT_CHANGE: usize = 10;
+const LARGE_COUNT_CHANGE_PERCENT: usize = 100;
+const SMALL_COUNT_CHANGE: usize = 10;

 /// Format old and new lines in OLD and NEW colors.
 ///
@@ -55,11 +55,14 @@ pub fn format(old_text: &str, new_text: &str) -> Vec<String> {
         return simple_format(old_text, new_text);
     }

-    // This check makes us faster, please use the benchmark.py script before and
-    // after if you change this.
+    // These checks make us faster, please use the benchmark.py script before
+    // and after if you change this.
     if is_large_byte_count_change(old_text, new_text) {
         return simple_format(old_text, new_text);
     }
+    if is_large_newline_count_change(old_text, new_text) {
+        return simple_format(old_text, new_text);
+    }

     // Find diffs between adds and removals
     let mut old_collector = TokenCollector::create(StyledToken::new("-".to_string(), Style::Old));