]> granicus.if.org Git - vim/commitdiff
patch 8.1.1922: in diff mode global operations can be very slow v8.1.1922
authorBram Moolenaar <Bram@vim.org>
Sat, 24 Aug 2019 18:54:19 +0000 (20:54 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 24 Aug 2019 18:54:19 +0000 (20:54 +0200)
Problem:    In diff mode global operations can be very slow.
Solution:   Do not call diff_redraw() many times, call it once when redrawing.
            And also don't update folds multiple times.

src/diff.c
src/fold.c
src/globals.h
src/proto/diff.pro
src/screen.c
src/version.c

index 260fdd96d9672371e5bd24646d72f68e0afc0ccb..4c0041d41832d29b3c9a4a3230dbd9df0030732e 100644 (file)
@@ -75,7 +75,6 @@ static int diff_buf_idx_tp(buf_T *buf, tabpage_T *tp);
 static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T line2, long amount, long amount_after);
 static void diff_check_unchanged(tabpage_T *tp, diff_T *dp);
 static int diff_check_sanity(tabpage_T *tp, diff_T *dp);
-static void diff_redraw(int dofold);
 static int check_external_diff(diffio_T *diffio);
 static int diff_file(diffio_T *diffio);
 static int diff_equal_entry(diff_T *dp, int idx1, int idx2);
@@ -520,7 +519,8 @@ diff_mark_adjust_tp(
 
     if (tp == curtab)
     {
-       diff_redraw(TRUE);
+       // Don't redraw right away, this updates the diffs, which can be slow.
+       need_diff_redraw = TRUE;
 
        /* Need to recompute the scroll binding, may remove or add filler
         * lines (e.g., when adding lines above w_topline). But it's slow when
@@ -645,13 +645,14 @@ diff_check_sanity(tabpage_T *tp, diff_T *dp)
 /*
  * Mark all diff buffers in the current tab page for redraw.
  */
-    static void
+    void
 diff_redraw(
     int                dofold)     // also recompute the folds
 {
     win_T      *wp;
     int                n;
 
+    need_diff_redraw = FALSE;
     FOR_ALL_WINDOWS(wp)
        if (wp->w_p_diff)
        {
index 482d3c96822aa7da9af7ebfbc2df0500f91da85b..6200578fced2554e7baceb6a1d847c45f5ed5c24 100644 (file)
@@ -813,6 +813,11 @@ foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
 
     if (disable_fold_update > 0)
        return;
+#ifdef FEAT_DIFF
+    if (need_diff_redraw)
+       // will update later
+       return;
+#endif
 
     /* Mark all folds from top to bot as maybe-small. */
     (void)foldFind(&wp->w_folds, top, &fp);
index d0837d3ff21819a95ba118fbe7cd290afb14ea6e..712a739e4fdb6f90712a4a59bb63da375c87ea7d 100644 (file)
@@ -1051,6 +1051,9 @@ EXTERN int        maptick INIT(= 0);      // tick for each non-mapped char
 EXTERN int     must_redraw INIT(= 0);      // type of redraw necessary
 EXTERN int     skip_redraw INIT(= FALSE);  // skip redraw once
 EXTERN int     do_redraw INIT(= FALSE);    // extra redraw once
+#ifdef FEAT_DIFF
+EXTERN int     need_diff_redraw INIT(= 0); // need to call diff_redraw()
+#endif
 
 EXTERN int     need_highlight_changed INIT(= TRUE);
 
index d6ab221da7421ba8a48555dceefe3fed3f261213..2ab6c546f857300aae791ad2c0a2069cd5860339 100644 (file)
@@ -4,6 +4,7 @@ void diff_buf_adjust(win_T *win);
 void diff_buf_add(buf_T *buf);
 void diff_invalidate(buf_T *buf);
 void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after);
+void diff_redraw(int dofold);
 int diff_internal(void);
 void ex_diffupdate(exarg_T *eap);
 void ex_diffpatch(exarg_T *eap);
index 5043c0d7ffab5234884caaf700e24501cea4e79e..1681e1c57d5037a3b5912dd3c05eebfb7f9cf6aa 100644 (file)
@@ -567,6 +567,12 @@ update_screen(int type_arg)
     }
 #endif
 
+#ifdef FEAT_DIFF
+    // May have postponed updating diffs.
+    if (need_diff_redraw)
+       diff_redraw(TRUE);
+#endif
+
     if (must_redraw)
     {
        if (type < must_redraw)     /* use maximal type */
index 58d86e55166767243aea6faaa981dd3b59fed7e9..862b3d9558b067aeb0d3665c1a18e6d8d000ff45 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1922,
 /**/
     1921,
 /**/