Mercurial > vim
changeset 27714:072c7ae27b06 v8.2.4383
patch 8.2.4383: Vim9: unused code lines
Commit: https://github.com/vim/vim/commit/7a3b802bab5add34baae37ec2c1ae7ad2f1693bd
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 14 19:53:03 2022 +0000
patch 8.2.4383: Vim9: unused code lines
Problem: Vim9: unused code lines.
Solution: Rely on either "cctx" or "cstack" to not be NULL.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Feb 2022 21:00:03 +0100 |
parents | 40bf82852134 |
children | 4cbf7a833468 |
files | src/version.c src/vim9compile.c |
diffstat | 2 files changed, 14 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4383, +/**/ 4382, /**/ 4381,
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -151,8 +151,7 @@ arg_exists( /* * Lookup a script-local variable in the current script, possibly defined in a * block that contains the function "cctx->ctx_ufunc". - * "cctx" is NULL at the script level. - * "cstack_T" is NULL in a function. + * "cctx" is NULL at the script level, "cstack" is NULL in a function. * If "len" is <= 0 "name" must be NUL terminated. * Return NULL when not found. */ @@ -185,21 +184,16 @@ find_script_var(char_u *name, size_t len if (cctx == NULL) { // Not in a function scope, find variable with block ID equal to or - // smaller than the current block id. If "cstack" is not NULL go up - // the block scopes (more accurate). + // smaller than the current block id. Use "cstack" to go up the block + // scopes. while (sav != NULL) { - if (cstack != NULL) - { - int idx; - - for (idx = cstack->cs_idx; idx >= 0; --idx) - if (cstack->cs_block_id[idx] == sav->sav_block_id) - break; - if (idx >= 0) + int idx; + + for (idx = cstack->cs_idx; idx >= 0; --idx) + if (cstack->cs_block_id[idx] == sav->sav_block_id) break; - } - else if (sav->sav_block_id <= si->sn_current_block_id) + if (idx >= 0) break; sav = sav->sav_next; } @@ -236,8 +230,7 @@ script_is_vim9() /* * Lookup a variable (without s: prefix) in the current script. - * "cctx" is NULL at the script level. - * "cstack" is NULL in a function. + * "cctx" is NULL at the script level, "cstack" is NULL in a function. * Returns OK or FAIL. */ int @@ -296,7 +289,8 @@ item_exists(char_u *name, size_t len, in /* * Check if "p[len]" is already defined, either in script "import_sid" or in - * compilation context "cctx". "cctx" is NULL at the script level. + * compilation context "cctx". + * "cctx" is NULL at the script level, "cstack" is NULL in a function. * Does not check the global namespace. * If "is_arg" is TRUE the error message is for an argument name. * Return FAIL and give an error if it defined. @@ -507,6 +501,7 @@ check_item_writable(svar_T *sv, int chec /* * Find "name" in script-local items of script "sid". * Pass "check_writable" to check_item_writable(). + * "cctx" is NULL at the script level, "cstack" is NULL in a function. * Returns the index in "sn_var_vals" if found. * If found but not in "sn_var_vals" returns -1. * If not found or the variable is not writable returns -2.