When splitting a window, all the location lists of the original window
are copied to the newly created one. If the newly created window is a
quickfix window or a location list window, the copied locations lists
are immediately destroyed. The attached patch prevents the copying if it
is unnecessary. This can shorten the execution time of the :copen,
:lopen, :cwindow, :lwindow commands significantly, particularly for
large location lists.
The speedup I measured varied between 4 and 50 times, depending on the
size of input. This might not be very meaningful, but my (very
subjective) feeling is that the comfort of getting a quickfix window
instantly is much greater than that of having to wait for 1.5 seconds.
--
Cheers,
Lech
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: src/quickfix.c
===================================================================
--- src/quickfix.c (revision 1352)
+++ src/quickfix.c (working copy)
@@ -2310,15 +2310,12 @@
if (eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
/* Create the new window at the very bottom. */
win_goto(lastwin);
- if (win_split(height, WSP_BELOW) == FAIL)
+ if (win_split(height, WSP_BELOW | WSP_QUICKFIX) == FAIL)
return; /* not enough room for window */
#ifdef FEAT_SCROLLBIND
curwin->w_p_scb = FALSE;
#endif
- /* Remove the location list for the quickfix window */
- qf_free_all(curwin);
-
if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
{
/*
Index: src/vim.h
===================================================================
--- src/vim.h (revision 1352)
+++ src/vim.h (working copy)
@@ -1057,6 +1057,7 @@
#define WSP_HELP 16 /* creating the help window */
#define WSP_BELOW 32 /* put new window below/right */
#define WSP_ABOVE 64 /* put new window above/left */
+#define WSP_QUICKFIX 128 /* creating a quickfix/location list window */
/*
* arguments for gui_set_shellsize()
Index: src/window.c
===================================================================
--- src/window.c (revision 1352)
+++ src/window.c (working copy)
@@ -12,7 +12,7 @@
static int path_is_url __ARGS((char_u *p));
#if defined(FEAT_WINDOWS) || defined(PROTO)
static int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
-static void win_init __ARGS((win_T *newp, win_T *oldp));
+static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
static void frame_setheight __ARGS((frame_T *curfrp, int height));
#ifdef FEAT_VERTSPLIT
@@ -913,7 +913,7 @@
return FAIL;
/* make the contents of the new window the same as the current one */
- win_init(wp, curwin);
+ win_init(wp, curwin, flags);
}
/*
@@ -1162,11 +1162,14 @@
* Initialize window "newp" from window "oldp".
* Used when splitting a window and when creating a new tab page.
* The windows will both edit the same buffer.
+ * WSP_QUICKFIX may be specified in flags to prevent the location list from
+ * being copied.
*/
static void
-win_init(newp, oldp)
+win_init(newp, oldp, flags)
win_T *newp;
win_T *oldp;
+ int flags;
{
int i;
@@ -1191,7 +1194,16 @@
copy_jumplist(oldp, newp);
#endif
#ifdef FEAT_QUICKFIX
- copy_loclist(oldp, newp);
+ if (flags & WSP_QUICKFIX) /* If we are creating a quickfix window or a
+ * location list window, we don't want the
+ * location list.
+ */
+ {
+ newp->w_llist = NULL;
+ newp->w_llist_ref = NULL;
+ }
+ else
+ copy_loclist(oldp, newp);
#endif
if (oldp->w_localdir != NULL)
newp->w_localdir = vim_strsave(oldp->w_localdir);
@@ -3221,7 +3233,7 @@
else
{
/* First window in new tab page, initialize it from "oldwin". */
- win_init(curwin, oldwin);
+ win_init(curwin, oldwin, 0);
# ifdef FEAT_SCROLLBIND
/* We don't want scroll-binding in the first window. */