changeset 9201:692e156c7023 v7.4.1884

commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 3 19:05:49 2016 +0200 patch 7.4.1884 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.
author Christian Brabandt <cb@256bit.org>
date Fri, 03 Jun 2016 19:15:05 +0200
parents 5f97922c67d7
children d8ec03e9096d
files src/quickfix.c src/structs.h src/version.c
diffstat 3 files changed, 52 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -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;
 }
 
 /*
--- a/src/structs.h
+++ b/src/structs.h
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1884,
+/**/
     1883,
 /**/
     1882,