Blob Blame History Raw
To: vim-dev@vim.org
Subject: Patch 7.2.120
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.120
Problem:    When opening the quickfix window or splitting the window and
            setting the location list, the location list is copied and then
            deleted, which is inefficient.
Solution:   Don't copy the location list when not needed. (Lech Lorens)
Files:      src/quickfix.c, src/vim.h, src/window.c


*** ../vim-7.2.119/src/quickfix.c	Sun Feb 22 00:01:42 2009
--- src/quickfix.c	Sat Feb 21 22:54:25 2009
***************
*** 1419,1424 ****
--- 1419,1425 ----
      int			opened_window = FALSE;
      win_T		*win;
      win_T		*altwin;
+     int			flags;
  #endif
      win_T		*oldwin = curwin;
      int			print_message = TRUE;
***************
*** 1531,1537 ****
      if (qf_ptr->qf_type == 1 && (!curwin->w_buffer->b_help || cmdmod.tab != 0))
      {
  	win_T	*wp;
- 	int	n;
  
  	if (cmdmod.tab != 0)
  	    wp = NULL;
--- 1532,1537 ----
***************
*** 1547,1559 ****
  	     * Split off help window; put it at far top if no position
  	     * specified, the current window is vertically split and narrow.
  	     */
! 	    n = WSP_HELP;
  # ifdef FEAT_VERTSPLIT
  	    if (cmdmod.split == 0 && curwin->w_width != Columns
  						      && curwin->w_width < 80)
! 		n |= WSP_TOP;
  # endif
! 	    if (win_split(0, n) == FAIL)
  		goto theend;
  	    opened_window = TRUE;	/* close it when fail */
  
--- 1547,1562 ----
  	     * Split off help window; put it at far top if no position
  	     * specified, the current window is vertically split and narrow.
  	     */
! 	    flags = WSP_HELP;
  # ifdef FEAT_VERTSPLIT
  	    if (cmdmod.split == 0 && curwin->w_width != Columns
  						      && curwin->w_width < 80)
! 		flags |= WSP_TOP;
  # endif
! 	    if (qi != &ql_info)
! 		flags |= WSP_NEWLOC;  /* don't copy the location list */
! 
! 	    if (win_split(0, flags) == FAIL)
  		goto theend;
  	    opened_window = TRUE;	/* close it when fail */
  
***************
*** 1563,1569 ****
  	    if (qi != &ql_info)	    /* not a quickfix list */
  	    {
  		/* The new window should use the supplied location list */
- 		qf_free_all(curwin);
  		curwin->w_llist = qi;
  		qi->qf_refcount++;
  	    }
--- 1566,1571 ----
***************
*** 1624,1630 ****
  	{
  	    ll_ref = curwin->w_llist_ref;
  
! 	    if (win_split(0, WSP_ABOVE) == FAIL)
  		goto failed;		/* not enough room for window */
  	    opened_window = TRUE;	/* close it when fail */
  	    p_swb = empty_option;	/* don't split again */
--- 1626,1635 ----
  	{
  	    ll_ref = curwin->w_llist_ref;
  
! 	    flags = WSP_ABOVE;
! 	    if (ll_ref != NULL)
! 		flags |= WSP_NEWLOC;
! 	    if (win_split(0, flags) == FAIL)
  		goto failed;		/* not enough room for window */
  	    opened_window = TRUE;	/* close it when fail */
  	    p_swb = empty_option;	/* don't split again */
***************
*** 1636,1642 ****
  	    {
  		/* The new window should use the location list from the
  		 * location list window */
- 		qf_free_all(curwin);
  		curwin->w_llist = ll_ref;
  		ll_ref->qf_refcount++;
  	    }
--- 1641,1646 ----
***************
*** 2311,2325 ****
  	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)
  	    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)
  	{
  	    /*
--- 2315,2326 ----
  	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 | WSP_NEWLOC) == FAIL)
  	    return;		/* not enough room for window */
  #ifdef FEAT_SCROLLBIND
  	curwin->w_p_scb = FALSE;
  #endif
  
  	if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
  	{
  	    /*
*** ../vim-7.2.119/src/vim.h	Thu Nov 20 14:11:47 2008
--- src/vim.h	Sat Feb 21 22:53:03 2009
***************
*** 1057,1062 ****
--- 1057,1063 ----
  #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_NEWLOC	128	/* don't copy location list */
  
  /*
   * arguments for gui_set_shellsize()
*** ../vim-7.2.119/src/window.c	Sat Feb 21 20:27:00 2009
--- src/window.c	Sat Feb 21 23:56:41 2009
***************
*** 12,18 ****
  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 frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
  static void frame_setheight __ARGS((frame_T *curfrp, int height));
  #ifdef FEAT_VERTSPLIT
--- 12,18 ----
  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, 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
***************
*** 911,917 ****
  	    return FAIL;
  
  	/* make the contents of the new window the same as the current one */
! 	win_init(wp, curwin);
      }
  
      /*
--- 911,917 ----
  	    return FAIL;
  
  	/* make the contents of the new window the same as the current one */
! 	win_init(wp, curwin, flags);
      }
  
      /*
***************
*** 1160,1170 ****
   * 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.
   */
      static void
! win_init(newp, oldp)
      win_T	*newp;
      win_T	*oldp;
  {
      int		i;
  
--- 1160,1174 ----
   * 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_NEWLOC may be specified in flags to prevent the location list from
+  * being copied.
   */
+ /*ARGSUSED*/
      static void
! win_init(newp, oldp, flags)
      win_T	*newp;
      win_T	*oldp;
+     int		 flags;
  {
      int		i;
  
***************
*** 1189,1195 ****
      copy_jumplist(oldp, newp);
  #endif
  #ifdef FEAT_QUICKFIX
!     copy_loclist(oldp, newp);
  #endif
      if (oldp->w_localdir != NULL)
  	newp->w_localdir = vim_strsave(oldp->w_localdir);
--- 1193,1206 ----
      copy_jumplist(oldp, newp);
  #endif
  #ifdef FEAT_QUICKFIX
!     if (flags & WSP_NEWLOC)
!     {
! 	/* Don't copy 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);
***************
*** 3219,3225 ****
      else
      {
  	/* First window in new tab page, initialize it from "oldwin". */
! 	win_init(curwin, oldwin);
  
  # ifdef FEAT_SCROLLBIND
  	/* We don't want scroll-binding in the first window. */
--- 3230,3236 ----
      else
      {
  	/* First window in new tab page, initialize it from "oldwin". */
! 	win_init(curwin, oldwin, 0);
  
  # ifdef FEAT_SCROLLBIND
  	/* We don't want scroll-binding in the first window. */
*** ../vim-7.2.119/src/version.c	Sun Feb 22 01:13:45 2009
--- src/version.c	Sun Feb 22 02:32:14 2009
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     120,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
110. You actually volunteer to become your employer's webmaster.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///