diff options
author | Paul Rigge <rigge@berkeley.edu> | 2018-01-01 21:15:22 -0800 |
---|---|---|
committer | Paul Rigge <rigge@berkeley.edu> | 2018-01-02 17:22:33 -0800 |
commit | 2e630d261157dbb902768ba8ef8346ee1eb41eb7 (patch) | |
tree | 67b152f2760453cd18b40740840aa24014b96200 | |
parent | 65ec4ea62972e021065d5a5be83b04bb8da2561a (diff) | |
download | rneovim-2e630d261157dbb902768ba8ef8346ee1eb41eb7.tar.gz rneovim-2e630d261157dbb902768ba8ef8346ee1eb41eb7.tar.bz2 rneovim-2e630d261157dbb902768ba8ef8346ee1eb41eb7.zip |
Refactor profiling check in call_user_func.
do_profiling is a global variable, and as such the clang static
analyzer has trouble making arguments about it.
This commit does one comparison against do_profiling and puts the
result in a local variable. This prevents errors from the value of
do_profiling changing between comparisons.
-rw-r--r-- | src/nvim/eval.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 555a0506d9..1c4dda0716 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -21254,15 +21254,17 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, } } + const bool do_profiling_yes = do_profiling == PROF_YES; + bool func_not_yet_profiling_but_should = - do_profiling == PROF_YES + do_profiling_yes && !fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL); if (func_not_yet_profiling_but_should) func_do_profile(fp); bool func_or_func_caller_profiling = - do_profiling == PROF_YES + do_profiling_yes && (fp->uf_profiling || (fc->caller != NULL && fc->caller->func->uf_profiling)); @@ -21272,7 +21274,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, fp->uf_tm_children = profile_zero(); } - if (do_profiling == PROF_YES) { + if (do_profiling_yes) { script_prof_save(&wait_start); } @@ -21348,7 +21350,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, sourcing_name = save_sourcing_name; sourcing_lnum = save_sourcing_lnum; current_SID = save_current_SID; - if (do_profiling == PROF_YES) + if (do_profiling_yes) script_prof_restore(&wait_start); if (p_verbose >= 12 && sourcing_name != NULL) { |