comparison src/autocmd.c @ 28397:d1702731786c v8.2.4723

patch 8.2.4723: the ModeChanged autocmd event is inefficient Commit: https://github.com/vim/vim/commit/2bf52dd065495cbf28e28792f2c2d50d44546d9f Author: LemonBoy <thatlemon@gmail.com> Date: Sat Apr 9 18:17:34 2022 +0100 patch 8.2.4723: the ModeChanged autocmd event is inefficient Problem: The ModeChanged autocmd event is inefficient. Solution: Avoid allocating memory. (closes https://github.com/vim/vim/issues/10134) Rename trigger_modechanged() to may_trigger_modechanged().
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 Apr 2022 19:30:02 +0200
parents e466fdbe0699
children 80ed5ad30d28
comparison
equal deleted inserted replaced
28396:cf018ac0499c 28397:d1702731786c
1238 1238
1239 #ifdef FEAT_EVAL 1239 #ifdef FEAT_EVAL
1240 // need to initialize last_mode for the first ModeChanged 1240 // need to initialize last_mode for the first ModeChanged
1241 // autocmd 1241 // autocmd
1242 if (event == EVENT_MODECHANGED && !has_modechanged()) 1242 if (event == EVENT_MODECHANGED && !has_modechanged())
1243 { 1243 get_mode(last_mode);
1244 typval_T rettv;
1245 typval_T tv[2];
1246
1247 tv[0].v_type = VAR_NUMBER;
1248 tv[0].vval.v_number = 1;
1249 tv[1].v_type = VAR_UNKNOWN;
1250 f_mode(tv, &rettv);
1251 STRCPY(last_mode, rettv.vval.v_string);
1252 vim_free(rettv.vval.v_string);
1253 }
1254 #endif 1244 #endif
1255 // Initialize the fields checked by the WinScrolled trigger to 1245 // Initialize the fields checked by the WinScrolled trigger to
1256 // stop it from firing right after the first autocmd is defined. 1246 // stop it from firing right after the first autocmd is defined.
1257 if (event == EVENT_WINSCROLLED && !has_winscrolled()) 1247 if (event == EVENT_WINSCROLLED && !has_winscrolled())
1258 { 1248 {