vim-patch:8.2.4723: the ModeChanged autocmd event is inefficient

Problem:    The ModeChanged autocmd event is inefficient.
Solution:   Avoid allocating memory. (closes vim/vim#10134)  Rename
            trigger_modechanged() to may_trigger_modechanged().
2bf52dd065

Make v:event readonly for ModeChanged.
This commit is contained in:
zeertzjq
2022-04-10 07:20:35 +08:00
parent ff726cc569
commit 263a7fde35
12 changed files with 77 additions and 71 deletions

View File

@@ -1083,8 +1083,7 @@ int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int gro
// need to initialize last_mode for the first ModeChanged autocmd
if (event == EVENT_MODECHANGED && !has_event(EVENT_MODECHANGED)) {
xfree(last_mode);
last_mode = get_mode();
get_mode(last_mode);
}
// If the event is CursorMoved, update the last cursor position