summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0130
blob: ba2232eed14889cfca753f9a5fef80dfca4241ae (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0130
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0130
Problem:    ":profdel func" does not work if func was called already.
            (Dominique Pelle)
Solution:   Reset uf_profiling and add a flag to indicate initialization was
            done.
Files:	    src/structs.h, src/userfunc.c


*** ../vim-8.1.0129/src/structs.h	2018-06-23 19:22:45.614486258 +0200
--- src/structs.h	2018-06-30 18:12:48.678664711 +0200
***************
*** 1345,1350 ****
--- 1345,1351 ----
      garray_T	uf_lines;	/* function lines */
  #ifdef FEAT_PROFILE
      int		uf_profiling;	/* TRUE when func is being profiled */
+     int		uf_prof_initialized;
      /* profiling the function as a whole */
      int		uf_tm_count;	/* nr of calls */
      proftime_T	uf_tm_total;	/* time spent in function + children */
*** ../vim-8.1.0129/src/userfunc.c	2018-05-22 18:31:30.001365739 +0200
--- src/userfunc.c	2018-06-30 18:20:15.704075693 +0200
***************
*** 293,302 ****
  	    fp->uf_scoped = NULL;
  
  #ifdef FEAT_PROFILE
- 	fp->uf_tml_count = NULL;
- 	fp->uf_tml_total = NULL;
- 	fp->uf_tml_self = NULL;
- 	fp->uf_profiling = FALSE;
  	if (prof_def_func())
  	    func_do_profile(fp);
  #endif
--- 293,298 ----
***************
*** 706,711 ****
--- 702,708 ----
  #ifdef FEAT_PROFILE
      proftime_T	wait_start;
      proftime_T	call_start;
+     int		started_profiling = FALSE;
  #endif
  
      /* If depth of calling is getting too high, don't execute the function */
***************
*** 921,927 ****
--- 918,927 ----
      if (do_profiling == PROF_YES)
      {
  	if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL))
+ 	{
+ 	    started_profiling = TRUE;
  	    func_do_profile(fp);
+ 	}
  	if (fp->uf_profiling
  		    || (fc->caller != NULL && fc->caller->func->uf_profiling))
  	{
***************
*** 965,970 ****
--- 965,973 ----
  	    profile_add(&fc->caller->func->uf_tm_children, &call_start);
  	    profile_add(&fc->caller->func->uf_tml_children, &call_start);
  	}
+ 	if (started_profiling)
+ 	    // make a ":profdel func" stop profiling the function
+ 	    fp->uf_profiling = FALSE;
      }
  #endif
  
***************
*** 2522,2544 ****
  {
      int		len = fp->uf_lines.ga_len;
  
!     if (len == 0)
! 	len = 1;  /* avoid getting error for allocating zero bytes */
!     fp->uf_tm_count = 0;
!     profile_zero(&fp->uf_tm_self);
!     profile_zero(&fp->uf_tm_total);
!     if (fp->uf_tml_count == NULL)
! 	fp->uf_tml_count = (int *)alloc_clear((unsigned) (sizeof(int) * len));
!     if (fp->uf_tml_total == NULL)
! 	fp->uf_tml_total = (proftime_T *)alloc_clear((unsigned)
! 						  (sizeof(proftime_T) * len));
!     if (fp->uf_tml_self == NULL)
! 	fp->uf_tml_self = (proftime_T *)alloc_clear((unsigned)
! 						  (sizeof(proftime_T) * len));
!     fp->uf_tml_idx = -1;
!     if (fp->uf_tml_count == NULL || fp->uf_tml_total == NULL
! 						   || fp->uf_tml_self == NULL)
! 	return;	    /* out of memory */
  
      fp->uf_profiling = TRUE;
  }
--- 2525,2552 ----
  {
      int		len = fp->uf_lines.ga_len;
  
!     if (!fp->uf_prof_initialized)
!     {
! 	if (len == 0)
! 	    len = 1;  /* avoid getting error for allocating zero bytes */
! 	fp->uf_tm_count = 0;
! 	profile_zero(&fp->uf_tm_self);
! 	profile_zero(&fp->uf_tm_total);
! 	if (fp->uf_tml_count == NULL)
! 	    fp->uf_tml_count = (int *)alloc_clear(
! 					       (unsigned)(sizeof(int) * len));
! 	if (fp->uf_tml_total == NULL)
! 	    fp->uf_tml_total = (proftime_T *)alloc_clear(
! 					 (unsigned)(sizeof(proftime_T) * len));
! 	if (fp->uf_tml_self == NULL)
! 	    fp->uf_tml_self = (proftime_T *)alloc_clear(
! 					 (unsigned)(sizeof(proftime_T) * len));
! 	fp->uf_tml_idx = -1;
! 	if (fp->uf_tml_count == NULL || fp->uf_tml_total == NULL
! 						    || fp->uf_tml_self == NULL)
! 	    return;	    /* out of memory */
! 	fp->uf_prof_initialized = TRUE;
!     }
  
      fp->uf_profiling = TRUE;
  }
***************
*** 2568,2574 ****
  	{
  	    --todo;
  	    fp = HI2UF(hi);
! 	    if (fp->uf_profiling)
  	    {
  		if (sorttab != NULL)
  		    sorttab[st_len++] = fp;
--- 2576,2582 ----
  	{
  	    --todo;
  	    fp = HI2UF(hi);
! 	    if (fp->uf_prof_initialized)
  	    {
  		if (sorttab != NULL)
  		    sorttab[st_len++] = fp;
*** ../vim-8.1.0129/src/version.c	2018-06-30 17:09:23.039956879 +0200
--- src/version.c	2018-06-30 18:12:14.990860555 +0200
***************
*** 791,792 ****
--- 791,794 ----
  {   /* Add new patch number below this line */
+ /**/
+     130,
  /**/


-- 
hundred-and-one symptoms of being an internet addict:
149. You find your computer sexier than your girlfriend

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///