summaryrefslogtreecommitdiff
path: root/src/keymap.c
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2020-10-18 00:02:55 +0200
committerStefan Kangas <stefan@marxist.se>2020-10-18 17:25:23 +0200
commitafde53cd81c7817c5b3187e60e7a49790e0af832 (patch)
tree93ea775eaa564b54793326f8dbee8209fbc6cecc /src/keymap.c
parent5ad2bb0fa95d9c9ae2387c963b453f695577450a (diff)
downloademacs-afde53cd81c7817c5b3187e60e7a49790e0af832.tar.gz
Improve substitute-command-keys performance
The previous conversion of describe_vector from C to Lisp for the keymap and char table case lead to an unacceptable performance hit. Moving back to the C version, as we do here, makes this function around 50 times faster. The Lisp version of `substitute-command-keys' was benchmarked using the form `(documentation 'dired-mode)', which now takes less than 8 ms on my machine. This is around 16 times slower than the previous C version. Thanks to Stefan Monnier for helpful pointers on benchmarking. * src/keymap.c (Fhelp__describe_vector): New defun to expose describe_vector to Lisp for keymaps and char tables. (syms_of_keymap): New defsubr for Fhelp__describe_vector. * lisp/help.el (describe-map): Use above defun instead of Lisp version. (help--describe-vector): Remove defun; keep it commented out for now.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 9d12c3a47d5..5ae8da6a05a 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -3328,6 +3328,40 @@ DESCRIBER is the output function used; nil means use `princ'. */)
return unbind_to (count, Qnil);
}
+DEFUN ("help--describe-vector", Fhelp__describe_vector, Shelp__describe_vector, 7, 7, 0,
+ doc: /* Insert in the current buffer a description of the contents of VECTOR.
+
+PREFIX is a string describing the key which leads to the keymap that
+this vector is in.
+
+If PARTIAL, it means do not mention suppressed commands.
+
+SHADOW is a list of keymaps that shadow this map.
+If it is non-nil, look up the key in those maps and don't mention it
+if it is defined by any of them.
+
+ENTIRE-MAP is the keymap in which this vector appears.
+If the definition in effect in the whole map does not match
+the one in this keymap, we ignore this one. */)
+ (Lisp_Object vector, Lisp_Object prefix, Lisp_Object transl,
+ Lisp_Object partial, Lisp_Object shadow, Lisp_Object entire_map,
+ Lisp_Object mention_shadow)
+{
+ ptrdiff_t count = SPECPDL_INDEX ();
+ specbind (Qstandard_output, Fcurrent_buffer ());
+ CHECK_VECTOR_OR_CHAR_TABLE (vector);
+
+ bool b_transl = NILP (transl) ? false : true;
+ bool b_partial = NILP (partial) ? false : true;
+ bool b_mention_shadow = NILP (mention_shadow) ? false : true;
+
+ describe_vector (vector, prefix, Qnil,
+ b_transl ? describe_translation : describe_command,
+ b_partial, shadow, entire_map,
+ true, b_mention_shadow);
+ return unbind_to (count, Qnil);
+}
+
/* Insert in the current buffer a description of the contents of VECTOR.
We call ELT_DESCRIBER to insert the description of one value found
in VECTOR.
@@ -3726,6 +3760,7 @@ be preferred. */);
defsubr (&Saccessible_keymaps);
defsubr (&Skey_description);
defsubr (&Skeymap__get_keyelt);
+ defsubr (&Shelp__describe_vector);
defsubr (&Sdescribe_vector);
defsubr (&Ssingle_key_description);
defsubr (&Stext_char_description);