patch 9.1.1179: too many strlen() calls in misc2.c
Problem: too many strlen() calls in misc2.c
Solution: refactor misc2.c and use bsearch() instead of a linear search
to find matches in the key_names_table array (John Marriott).
This commit changes misc2.c to use bsearch() to perform string searches of
the key_names_table array.
Implementation detail:
- Some entries in this array have alternate names. Add field alt_name to
point to the alternate name.
- Some entries in this array are only available if a given feature is
defined. Keep them in the array, but add a boolean field enabled to
indicate if the record can be used or not. If the feature is not
available, the corresponding enabled field is set to FALSE.
In my measurements running the test suite on a huge non-gui build on
linux, the number of string comparisons in get_special_key_code():
Before (linear search): 2,214,957
After (binary search): 297,770
A side effect of this is 1477 calls to STRLEN() in
get_special_key_name() for the same test run are no longer necessary.
While we are here, refactor call_shell() and the mshape_names array to
remove some STRLEN() calls.
closes: #16788
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/version.c b/src/version.c
index a7ce796..973b1b6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1179,
+/**/
1178,
/**/
1177,