Patch 8.1.1922
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.
Files:      src/globals.h, src/diff.c, src/proto/diff.pro, src/screen.c,
            src/fold.c


*** ../vim-8.1.1921/src/globals.h       2019-08-21 14:36:29.395376065 +0200
--- src/globals.h       2019-08-23 22:55:11.879863137 +0200
***************
*** 1051,1056 ****
--- 1051,1059 ----
  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);
  
*** ../vim-8.1.1921/src/diff.c  2019-05-28 23:08:12.056648758 +0200
--- src/diff.c  2019-08-23 23:02:26.629864159 +0200
***************
*** 75,81 ****
  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);
--- 75,80 ----
***************
*** 520,526 ****
  
      if (tp == curtab)
      {
!       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
--- 519,526 ----
  
      if (tp == curtab)
      {
!       // 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,657 ****
  /*
   * Mark all diff buffers in the current tab page for redraw.
   */
!     static void
  diff_redraw(
      int               dofold)     // also recompute the folds
  {
      win_T     *wp;
      int               n;
  
      FOR_ALL_WINDOWS(wp)
        if (wp->w_p_diff)
        {
--- 645,658 ----
  /*
   * Mark all diff buffers in the current tab page for redraw.
   */
!     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)
        {
*** ../vim-8.1.1921/src/proto/diff.pro  2018-09-16 14:10:28.300323360 +0200
--- src/proto/diff.pro  2019-08-23 23:02:15.213918063 +0200
***************
*** 4,9 ****
--- 4,10 ----
  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);
*** ../vim-8.1.1921/src/screen.c        2019-08-21 14:36:29.391376081 +0200
--- src/screen.c        2019-08-23 23:01:25.614151594 +0200
***************
*** 567,572 ****
--- 567,578 ----
      }
  #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 */
*** ../vim-8.1.1921/src/fold.c  2019-08-19 22:48:27.173038748 +0200
--- src/fold.c  2019-08-23 23:10:05.047663934 +0200
***************
*** 813,818 ****
--- 813,823 ----
  
      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);
*** ../vim-8.1.1921/src/version.c       2019-08-24 20:49:58.829320278 +0200
--- src/version.c       2019-08-24 20:53:03.960246041 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1922,
  /**/

-- 
Nobody will ever need more than 640 kB RAM.
                -- Bill Gates, 1983
Windows 98 requires 16 MB RAM.
                -- Bill Gates, 1999
Logical conclusion: Nobody will ever need Windows 98.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201908241854.x7OIswI4025428%40masaka.moolenaar.net.

Raspunde prin e-mail lui