1
0
forked from aniani/vim

patch 7.4.2104

Problem:    Code duplication when unreferencing a function.
Solution:   De-duplicate.
This commit is contained in:
Bram Moolenaar
2016-07-26 20:46:08 +02:00
parent e99e84497b
commit 97baee80f0
2 changed files with 11 additions and 16 deletions

View File

@@ -2640,11 +2640,11 @@ ex_delfunction(exarg_T *eap)
void void
func_unref(char_u *name) func_unref(char_u *name)
{ {
ufunc_T *fp; ufunc_T *fp = NULL;
if (name == NULL) if (name == NULL)
return; return;
else if (isdigit(*name)) if (isdigit(*name))
{ {
fp = find_func(name); fp = find_func(name);
if (fp == NULL) if (fp == NULL)
@@ -2654,18 +2654,12 @@ func_unref(char_u *name)
#endif #endif
EMSG2(_(e_intern2), "func_unref()"); EMSG2(_(e_intern2), "func_unref()");
} }
else if (--fp->uf_refcount <= 0)
{
/* Only delete it when it's not being used. Otherwise it's done
* when "uf_calls" becomes zero. */
if (fp->uf_calls == 0)
func_free(fp);
}
} }
else if (STRNCMP(name, "<lambda>", 8) == 0) else if (STRNCMP(name, "<lambda>", 8) == 0)
{ {
/* fail silently, when lambda function isn't found. */ /* fail silently, when lambda function isn't found. */
fp = find_func(name); fp = find_func(name);
}
if (fp != NULL && --fp->uf_refcount <= 0) if (fp != NULL && --fp->uf_refcount <= 0)
{ {
/* Only delete it when it's not being used. Otherwise it's done /* Only delete it when it's not being used. Otherwise it's done
@@ -2674,7 +2668,6 @@ func_unref(char_u *name)
func_free(fp); func_free(fp);
} }
} }
}
/* /*
* Count a reference to a Function. * Count a reference to a Function.

View File

@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2104,
/**/ /**/
2103, 2103,
/**/ /**/