summaryrefslogtreecommitdiffstats
path: root/gvim/vim-7.2/7.2.021
blob: fee0bd85ca4e5cd0eeae4caabe55369640fa6fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
To: vim-dev@vim.org
Subject: Patch 7.2.021
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.021
Problem:    When executing autocommands getting the full file name may be
	    slow. (David Kotchan)
Solution:   Postpone calling FullName_save() until autocmd_fname is used.
Files:	    src/ex_docmd.c, src/fileio.c, src/globals.h


*** ../vim-7.2.020/src/ex_docmd.c	Thu Sep 18 12:43:21 2008
--- src/ex_docmd.c	Mon Sep 15 20:04:53 2008
***************
*** 9542,9547 ****
--- 9569,9583 ----
  #ifdef FEAT_AUTOCMD
  	case SPEC_AFILE:	/* file name for autocommand */
  		result = autocmd_fname;
+ 		if (result != NULL && !autocmd_fname_full)
+ 		{
+ 		    /* Still need to turn the fname into a full path.  It is
+ 		     * postponed to avoid a delay when <afile> is not used. */
+ 		    autocmd_fname_full = TRUE;
+ 		    result = FullName_save(autocmd_fname, FALSE);
+ 		    vim_free(autocmd_fname);
+ 		    autocmd_fname = result;
+ 		}
  		if (result == NULL)
  		{
  		    *errormsg = (char_u *)_("E495: no autocommand file name to substitute for \"<afile>\"");
*** ../vim-7.2.020/src/fileio.c	Wed Aug  6 18:43:07 2008
--- src/fileio.c	Tue Sep 16 21:24:26 2008
***************
*** 8523,8528 ****
--- 8523,8529 ----
      char_u	*save_sourcing_name;
      linenr_T	save_sourcing_lnum;
      char_u	*save_autocmd_fname;
+     int		save_autocmd_fname_full;
      int		save_autocmd_bufnr;
      char_u	*save_autocmd_match;
      int		save_autocmd_busy;
***************
*** 8601,8606 ****
--- 8602,8608 ----
       * Save the autocmd_* variables and info about the current buffer.
       */
      save_autocmd_fname = autocmd_fname;
+     save_autocmd_fname_full = autocmd_fname_full;
      save_autocmd_bufnr = autocmd_bufnr;
      save_autocmd_match = autocmd_match;
      save_autocmd_busy = autocmd_busy;
***************
*** 8618,8631 ****
  	if (fname != NULL && *fname != NUL)
  	    autocmd_fname = fname;
  	else if (buf != NULL)
! 	    autocmd_fname = buf->b_fname;
  	else
  	    autocmd_fname = NULL;
      }
      else
  	autocmd_fname = fname_io;
      if (autocmd_fname != NULL)
! 	autocmd_fname = FullName_save(autocmd_fname, FALSE);
  
      /*
       * Set the buffer number to be used for <abuf>.
--- 8620,8634 ----
  	if (fname != NULL && *fname != NUL)
  	    autocmd_fname = fname;
  	else if (buf != NULL)
! 	    autocmd_fname = buf->b_ffname;
  	else
  	    autocmd_fname = NULL;
      }
      else
  	autocmd_fname = fname_io;
      if (autocmd_fname != NULL)
! 	autocmd_fname = vim_strsave(autocmd_fname);
!     autocmd_fname_full = FALSE; /* call FullName_save() later */
  
      /*
       * Set the buffer number to be used for <abuf>.
***************
*** 8810,8815 ****
--- 8813,8819 ----
      sourcing_lnum = save_sourcing_lnum;
      vim_free(autocmd_fname);
      autocmd_fname = save_autocmd_fname;
+     autocmd_fname_full = save_autocmd_fname_full;
      autocmd_bufnr = save_autocmd_bufnr;
      autocmd_match = save_autocmd_match;
  #ifdef FEAT_EVAL
***************
*** 8918,8924 ****
      {
  	apc->curpat = NULL;
  
! 	/* only use a pattern when it has not been removed, has commands and
  	 * the group matches. For buffer-local autocommands only check the
  	 * buffer number. */
  	if (ap->pat != NULL && ap->cmds != NULL
--- 8922,8928 ----
      {
  	apc->curpat = NULL;
  
! 	/* Only use a pattern when it has not been removed, has commands and
  	 * the group matches. For buffer-local autocommands only check the
  	 * buffer number. */
  	if (ap->pat != NULL && ap->cmds != NULL
*** ../vim-7.2.020/src/globals.h	Sat Jul 26 16:04:49 2008
--- src/globals.h	Mon Sep 15 19:59:28 2008
***************
*** 1022,1027 ****
--- 1022,1028 ----
  #endif
  #ifdef FEAT_AUTOCMD
  EXTERN char_u	*autocmd_fname INIT(= NULL); /* fname for <afile> on cmdline */
+ EXTERN int	autocmd_fname_full;	     /* autocmd_fname is full path */
  EXTERN int	autocmd_bufnr INIT(= 0);     /* fnum for <abuf> on cmdline */
  EXTERN char_u	*autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */
  EXTERN int	did_cursorhold INIT(= FALSE); /* set when CursorHold t'gerd */
*** ../vim-7.2.020/src/version.c	Thu Sep 18 20:55:19 2008
--- src/version.c	Thu Sep 18 21:24:30 2008
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     21,
  /**/

-- 
From "know your smileys":
 :----}  You lie like Pinocchio

 /// 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    ///