patch 8.2.4252: generating the normal command table at runtime is inefficient
Problem: Generating the normal command table at runtime is inefficient.
Solution: Generate the table with a Vim script and put it in a header file.
(Yegappan Lakshmanan, closes #9648)
diff --git a/src/Makefile b/src/Makefile
index cdb491b..549b817 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2144,6 +2144,16 @@
cmdidxs: ex_cmds.h
vim --clean -X --not-a-term -u create_cmdidxs.vim
+# Run vim script to generate the normal/visual mode command lookup table.
+# This only needs to be run when a new normal/visual mode command has been
+# added. If this fails because you don't have Vim yet:
+# - change nv_cmds[] in normal.c to add the new normal/visual mode command.
+# - build Vim
+# - run "make nvcmdidxs" using the new Vim to generate nv_cmdidxs.h
+# - rebuild Vim to use the newly generated nv_cmdidxs.h file.
+nvcmdidxs: normal.c
+ ./$(VIMTARGET) --clean -X --not-a-term -u create_nvcmdidxs.vim
+
# The normal command to compile a .c file to its .o file.
# Without or with ALL_CFLAGS.
@@ -4002,7 +4012,7 @@
objects/normal.o: normal.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
- proto.h globals.h errors.h
+ proto.h globals.h errors.h nv_cmdidxs.h
objects/ops.o: ops.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \