]> granicus.if.org Git - vim/commitdiff
patch 7.4.1884 v7.4.1884
authorBram Moolenaar <Bram@vim.org>
Fri, 3 Jun 2016 17:05:49 +0000 (19:05 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 3 Jun 2016 17:05:49 +0000 (19:05 +0200)
Problem:    Updating marks in a quickfix list is very slow when the list is
            long.
Solution:   Only update marks if the buffer has a quickfix entry.

src/quickfix.c
src/structs.h
src/version.c

index 23b1705b33411e0f1fec863a3bfb9902f5a5a5ef..b72f7d1f681e0e70e30296b2b83966a13430b42e 100644 (file)
@@ -1178,7 +1178,13 @@ qf_add_entry(
     if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
        return FAIL;
     if (bufnum != 0)
+    {
+       buf_T *buf = buflist_findnr(bufnum);
+
        qfp->qf_fnum = bufnum;
+       if (buf != NULL)
+           buf->b_has_qf_entry = TRUE;
+    }
     else
        qfp->qf_fnum = qf_get_fnum(dir, fname);
     if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
@@ -1378,50 +1384,54 @@ copy_loclist(win_T *from, win_T *to)
 }
 
 /*
- * get buffer number for file "dir.name"
+ * Get buffer number for file "dir.name".
+ * Also sets the b_has_qf_entry flag.
  */
     static int
 qf_get_fnum(char_u *directory, char_u *fname)
 {
+    char_u     *ptr;
+    buf_T      *buf;
+
     if (fname == NULL || *fname == NUL)                /* no file name */
        return 0;
-    {
-       char_u      *ptr;
-       int         fnum;
 
 #ifdef VMS
-       vms_remove_version(fname);
+    vms_remove_version(fname);
 #endif
 #ifdef BACKSLASH_IN_FILENAME
-       if (directory != NULL)
-           slash_adjust(directory);
-       slash_adjust(fname);
+    if (directory != NULL)
+       slash_adjust(directory);
+    slash_adjust(fname);
 #endif
-       if (directory != NULL && !vim_isAbsName(fname)
-               && (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
+    if (directory != NULL && !vim_isAbsName(fname)
+           && (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
+    {
+       /*
+        * Here we check if the file really exists.
+        * This should normally be true, but if make works without
+        * "leaving directory"-messages we might have missed a
+        * directory change.
+        */
+       if (mch_getperm(ptr) < 0)
        {
-           /*
-            * Here we check if the file really exists.
-            * This should normally be true, but if make works without
-            * "leaving directory"-messages we might have missed a
-            * directory change.
-            */
-           if (mch_getperm(ptr) < 0)
-           {
-               vim_free(ptr);
-               directory = qf_guess_filepath(fname);
-               if (directory)
-                   ptr = concat_fnames(directory, fname, TRUE);
-               else
-                   ptr = vim_strsave(fname);
-           }
-           /* Use concatenated directory name and file name */
-           fnum = buflist_add(ptr, 0);
            vim_free(ptr);
-           return fnum;
+           directory = qf_guess_filepath(fname);
+           if (directory)
+               ptr = concat_fnames(directory, fname, TRUE);
+           else
+               ptr = vim_strsave(fname);
        }
-       return buflist_add(fname, 0);
+       /* Use concatenated directory name and file name */
+       buf = buflist_new(ptr, NULL, (linenr_T)0, 0);
+       vim_free(ptr);
     }
+    else
+       buf = buflist_new(fname, NULL, (linenr_T)0, 0);
+    if (buf == NULL)
+       return 0;
+    buf->b_has_qf_entry = TRUE;
+    return buf->b_fnum;
 }
 
 /*
@@ -2414,7 +2424,10 @@ qf_mark_adjust(
     qfline_T   *qfp;
     int                idx;
     qf_info_T  *qi = &ql_info;
+    int                found_one = FALSE;
 
+    if (!curbuf->b_has_qf_entry)
+       return;
     if (wp != NULL)
     {
        if (wp->w_llist == NULL)
@@ -2429,6 +2442,7 @@ qf_mark_adjust(
                       ++i, qfp = qfp->qf_next)
                if (qfp->qf_fnum == curbuf->b_fnum)
                {
+                   found_one = TRUE;
                    if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2)
                    {
                        if (amount == MAXLNUM)
@@ -2439,6 +2453,9 @@ qf_mark_adjust(
                    else if (amount_after && qfp->qf_lnum > line2)
                        qfp->qf_lnum += amount_after;
                }
+
+    if (!found_one)
+       curbuf->b_has_qf_entry = FALSE;
 }
 
 /*
index 08d3325431c8ff30db8608f3bf7c87c8b4cb5b9d..d9498e4d934e3c62c084598484c38c9715b76427 100644 (file)
@@ -1865,9 +1865,10 @@ struct file_buffer
 #ifdef FEAT_MBYTE
     int                b_p_bomb;       /* 'bomb' */
 #endif
-#if defined(FEAT_QUICKFIX)
+#ifdef FEAT_QUICKFIX
     char_u     *b_p_bh;        /* 'bufhidden' */
     char_u     *b_p_bt;        /* 'buftype' */
+    int                b_has_qf_entry;
 #endif
     int                b_p_bl;         /* 'buflisted' */
 #ifdef FEAT_CINDENT
@@ -2465,7 +2466,7 @@ struct window_S
     int                w_wrow, w_wcol;     /* cursor position in window */
 
     linenr_T   w_botline;          /* number of the line below the bottom of
-                                      the screen */
+                                      the window */
     int                w_empty_rows;       /* number of ~ rows in window */
 #ifdef FEAT_DIFF
     int                w_filler_rows;      /* number of filler rows at the end of the
index 6278002e902f5121011108761318e459d1238b2e..0f9e840caf4a3f0d03f3d6e7d8b57d54e71b2043 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1884,
 /**/
     1883,
 /**/