comparison src/userfunc.c @ 32230:eee30cf13301 v9.0.1446

patch 9.0.1446: unnecessary checks for the "skip" flag when skipping Commit: https://github.com/vim/vim/commit/5299c0933f942c61bfd48064c91365e518fa868c Author: zeertzjq <zeertzjq@outlook.com> Date: Wed Apr 12 20:48:16 2023 +0100 patch 9.0.1446: unnecessary checks for the "skip" flag when skipping Problem: Unnecessary checks for the "skip" flag when skipping. Solution: Remove the unnecessary checks. (closes https://github.com/vim/vim/issues/12254)
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Apr 2023 22:00:03 +0200
parents 97255d909654
children 6e96bd314ffe
comparison
equal deleted inserted replaced
32229:bbdf3ccfbc3e 32230:eee30cf13301
5866 if (eap->skip) 5866 if (eap->skip)
5867 --emsg_skip; 5867 --emsg_skip;
5868 clear_evalarg(&evalarg, eap); 5868 clear_evalarg(&evalarg, eap);
5869 } 5869 }
5870 5870
5871 /*
5872 * Lower level implementation of "call". Only called when not skipping.
5873 */
5871 static int 5874 static int
5872 ex_call_inner( 5875 ex_call_inner(
5873 exarg_T *eap, 5876 exarg_T *eap,
5874 char_u *name, 5877 char_u *name,
5875 char_u **arg, 5878 char_u **arg,
5880 linenr_T lnum; 5883 linenr_T lnum;
5881 int doesrange; 5884 int doesrange;
5882 typval_T rettv; 5885 typval_T rettv;
5883 int failed = FALSE; 5886 int failed = FALSE;
5884 5887
5885 /* 5888 lnum = eap->line1;
5886 * When skipping, evaluate the function once, to find the end of the
5887 * arguments.
5888 * When the function takes a range, this is discovered after the first
5889 * call, and the loop is broken.
5890 */
5891 if (eap->skip)
5892 {
5893 ++emsg_skip;
5894 lnum = eap->line2; // do it once, also with an invalid range
5895 }
5896 else
5897 lnum = eap->line1;
5898 for ( ; lnum <= eap->line2; ++lnum) 5889 for ( ; lnum <= eap->line2; ++lnum)
5899 { 5890 {
5900 funcexe_T funcexe; 5891 funcexe_T funcexe;
5901 5892
5902 if (!eap->skip && eap->addr_count > 0) 5893 if (eap->addr_count > 0)
5903 { 5894 {
5904 if (lnum > curbuf->b_ml.ml_line_count) 5895 if (lnum > curbuf->b_ml.ml_line_count)
5905 { 5896 {
5906 // If the function deleted lines or switched to another buffer 5897 // If the function deleted lines or switched to another buffer
5907 // the line number may become invalid. 5898 // the line number may become invalid.
5925 if (has_watchexpr()) 5916 if (has_watchexpr())
5926 dbg_check_breakpoint(eap); 5917 dbg_check_breakpoint(eap);
5927 5918
5928 // Handle a function returning a Funcref, Dictionary or List. 5919 // Handle a function returning a Funcref, Dictionary or List.
5929 if (handle_subscript(arg, NULL, &rettv, 5920 if (handle_subscript(arg, NULL, &rettv,
5930 eap->skip ? NULL : &EVALARG_EVALUATE, TRUE) == FAIL) 5921 &EVALARG_EVALUATE, TRUE) == FAIL)
5931 { 5922 {
5932 failed = TRUE; 5923 failed = TRUE;
5933 break; 5924 break;
5934 } 5925 }
5935 5926
5936 clear_tv(&rettv); 5927 clear_tv(&rettv);
5937 if (doesrange || eap->skip) 5928 if (doesrange)
5938 break; 5929 break;
5939 5930
5940 // Stop when immediately aborting on error, or when an interrupt 5931 // Stop when immediately aborting on error, or when an interrupt
5941 // occurred or an exception was thrown but not caught. 5932 // occurred or an exception was thrown but not caught.
5942 // get_func_tv() returned OK, so that the check for trailing 5933 // get_func_tv() returned OK, so that the check for trailing
5943 // characters below is executed. 5934 // characters below is executed.
5944 if (aborting()) 5935 if (aborting())
5945 break; 5936 break;
5946 } 5937 }
5947 if (eap->skip)
5948 --emsg_skip;
5949 return failed; 5938 return failed;
5950 } 5939 }
5951 5940
5952 /* 5941 /*
5953 * Core part of ":defer func(arg)". "arg" points to the "(" and is advanced. 5942 * Core part of ":defer func(arg)". "arg" points to the "(" and is advanced.
6183 --emsg_skip; 6172 --emsg_skip;
6184 clear_evalarg(&evalarg, eap); 6173 clear_evalarg(&evalarg, eap);
6185 return; 6174 return;
6186 } 6175 }
6187 6176
6188 tofree = trans_function_name_ext(&arg, NULL, eap->skip, TFN_INT, 6177 tofree = trans_function_name_ext(&arg, NULL, FALSE, TFN_INT,
6189 &fudi, &partial, vim9script ? &type : NULL, NULL); 6178 &fudi, &partial, vim9script ? &type : NULL, NULL);
6190 if (fudi.fd_newkey != NULL) 6179 if (fudi.fd_newkey != NULL)
6191 { 6180 {
6192 // Still need to give an error message for missing key. 6181 // Still need to give an error message for missing key.
6193 semsg(_(e_key_not_present_in_dictionary_str), fudi.fd_newkey); 6182 semsg(_(e_key_not_present_in_dictionary_str), fudi.fd_newkey);
6237 funcexe.fe_partial = partial; 6226 funcexe.fe_partial = partial;
6238 funcexe.fe_selfdict = fudi.fd_dict; 6227 funcexe.fe_selfdict = fudi.fd_dict;
6239 funcexe.fe_firstline = eap->line1; 6228 funcexe.fe_firstline = eap->line1;
6240 funcexe.fe_lastline = eap->line2; 6229 funcexe.fe_lastline = eap->line2;
6241 funcexe.fe_found_var = found_var; 6230 funcexe.fe_found_var = found_var;
6242 funcexe.fe_evaluate = !eap->skip; 6231 funcexe.fe_evaluate = TRUE;
6243 failed = ex_call_inner(eap, name, &arg, startarg, &funcexe, &evalarg); 6232 failed = ex_call_inner(eap, name, &arg, startarg, &funcexe, &evalarg);
6244 } 6233 }
6245 6234
6246 // When inside :try we need to check for following "| catch" or "| endtry". 6235 // When inside :try we need to check for following "| catch" or "| endtry".
6247 // Not when there was an error, but do check if an exception was thrown. 6236 // Not when there was an error, but do check if an exception was thrown.