1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-03 11:33:37 +00:00

unbind_to performance tuning

* src/alloc.c (which_symbols):
* src/dispnew.c (Fredisplay):
* src/editfns.c (Fsubst_char_in_region):
* src/fileio.c (Fdo_auto_save):
* src/indent.c (Fvertical_motion):
* src/keymap.c (Fcurrent_active_maps):
* src/lread.c (Feval_buffer):
* src/minibuf.c (get_minibuffer):
* src/sysdep.c (system_process_attributes):
* src/textprop.c (Fnext_single_char_property_change)
(Fprevious_single_char_property_change):
* src/window.c (Fscroll_other_window, Fscroll_other_window_down):
* src/xdisp.c (Fformat_mode_line):
Help the compiler eliminate tail recursion in call to unbind_to.
* src/coding.c (decode_coding_gap):
Omit unnecessary unbind_to, as we’re about to call unbind_to anyway.
* src/coding.c (Fread_coding_system):
* src/eval.c (eval_sub):
* src/xdisp.c (handle_single_display_spec, decode_mode_spec):
* src/xselect.c (x_get_local_selection):
Avoid need to save a machine register when calling unbind_to.
* src/minibuf.c (Ftry_completion, Fall_completions):
Omit unnecessary assignment.
This commit is contained in:
Paul Eggert 2018-06-29 17:07:38 -07:00
parent 08594a975a
commit 2e2811865f
15 changed files with 39 additions and 56 deletions

View File

@ -7206,8 +7206,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
}
out:
unbind_to (gc_count, Qnil);
return found;
return unbind_to (gc_count, found);
}
#ifdef SUSPICIOUS_OBJECT_CHECKING

View File

@ -8005,7 +8005,6 @@ decode_coding_gap (struct coding_system *coding,
ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
Lisp_Object val;
Lisp_Object undo_list = BVAR (current_buffer, undo_list);
ptrdiff_t count1 = SPECPDL_INDEX ();
record_unwind_protect (coding_restore_undo_list,
Fcons (undo_list, Fcurrent_buffer ()));
@ -8016,7 +8015,6 @@ decode_coding_gap (struct coding_system *coding,
CHECK_NATNUM (val);
coding->produced_char += Z - prev_Z;
coding->produced += Z_BYTE - prev_Z_BYTE;
unbind_to (count1, Qnil);
}
unbind_to (count, Qnil);
@ -8545,7 +8543,7 @@ are lower-case). */)
val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
Qt, Qnil, Qcoding_system_history,
default_coding_system, Qnil);
unbind_to (count, Qnil);
val = unbind_to (count, val);
return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
}

View File

@ -5828,8 +5828,7 @@ immediately by pending input. */)
if (!NILP (force) && !redisplay_dont_pause)
specbind (Qredisplay_dont_pause, Qt);
redisplay_preserve_echo_area (2);
unbind_to (count, Qnil);
return Qt;
return unbind_to (count, Qt);
}

View File

@ -3531,8 +3531,7 @@ Both characters must have the same length of multi-byte form. */)
update_compositions (changed, last_changed, CHECK_ALL);
}
unbind_to (count, Qnil);
return Qnil;
return unbind_to (count, Qnil);
}

View File

@ -2366,7 +2366,7 @@ eval_sub (Lisp_Object form)
specbind (Qlexical_binding,
NILP (Vinternal_interpreter_environment) ? Qnil : Qt);
exp = apply1 (Fcdr (fun), original_args);
unbind_to (count1, Qnil);
exp = unbind_to (count1, exp);
val = eval_sub (exp);
}
else if (EQ (funcar, Qlambda)

View File

@ -5767,8 +5767,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
Vquit_flag = oquit;
/* This restores the message-stack status. */
unbind_to (count, Qnil);
return Qnil;
return unbind_to (count, Qnil);
}
DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved,

View File

@ -2356,9 +2356,7 @@ whether or not it is currently displayed in some window. */)
bidi_unshelve_cache (itdata, 0);
}
unbind_to (count, Qnil);
return make_number (it.vpos);
return unbind_to (count, make_number (it.vpos));
}

View File

@ -1608,9 +1608,7 @@ like in the respective argument of `key-binding'. */)
keymaps = Fcons (otlp, keymaps);
}
unbind_to (count, Qnil);
return keymaps;
return unbind_to (count, keymaps);
}
/* GC is possible in this function if it autoloads a keymap. */

View File

@ -2143,9 +2143,7 @@ This function preserves the position of point. */)
BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
readevalloop (buf, 0, filename,
!NILP (printflag), unibyte, Qnil, Qnil, Qnil);
unbind_to (count, Qnil);
return Qnil;
return unbind_to (count, Qnil);
}
DEFUN ("eval-region", Feval_region, Seval_region, 2, 4, "r",

View File

@ -755,7 +755,7 @@ get_minibuffer (EMACS_INT depth)
call0 (intern ("minibuffer-inactive-mode"));
else
Fkill_all_local_variables ();
unbind_to (count, Qnil);
buf = unbind_to (count, buf);
}
return buf;
@ -1274,11 +1274,12 @@ is used to further constrain the set of candidates. */)
for (regexps = Vcompletion_regexp_list; CONSP (regexps);
regexps = XCDR (regexps))
{
if (bindcount < 0) {
bindcount = SPECPDL_INDEX ();
specbind (Qcase_fold_search,
completion_ignore_case ? Qt : Qnil);
}
if (bindcount < 0)
{
bindcount = SPECPDL_INDEX ();
specbind (Qcase_fold_search,
completion_ignore_case ? Qt : Qnil);
}
tem = Fstring_match (XCAR (regexps), eltstring, zero);
if (NILP (tem))
break;
@ -1377,10 +1378,8 @@ is used to further constrain the set of candidates. */)
}
}
if (bindcount >= 0) {
if (bindcount >= 0)
unbind_to (bindcount, Qnil);
bindcount = -1;
}
if (NILP (bestmatch))
return Qnil; /* No completions found. */
@ -1534,11 +1533,12 @@ with a space are ignored unless STRING itself starts with a space. */)
for (regexps = Vcompletion_regexp_list; CONSP (regexps);
regexps = XCDR (regexps))
{
if (bindcount < 0) {
bindcount = SPECPDL_INDEX ();
specbind (Qcase_fold_search,
completion_ignore_case ? Qt : Qnil);
}
if (bindcount < 0)
{
bindcount = SPECPDL_INDEX ();
specbind (Qcase_fold_search,
completion_ignore_case ? Qt : Qnil);
}
tem = Fstring_match (XCAR (regexps), eltstring, zero);
if (NILP (tem))
break;
@ -1556,10 +1556,11 @@ with a space are ignored unless STRING itself starts with a space. */)
tem = Fcommandp (elt, Qnil);
else
{
if (bindcount >= 0) {
unbind_to (bindcount, Qnil);
bindcount = -1;
}
if (bindcount >= 0)
{
unbind_to (bindcount, Qnil);
bindcount = -1;
}
tem = type == 3
? call2 (predicate, elt,
HASH_VALUE (XHASH_TABLE (collection), idx - 1))
@ -1572,10 +1573,8 @@ with a space are ignored unless STRING itself starts with a space. */)
}
}
if (bindcount >= 0) {
if (bindcount >= 0)
unbind_to (bindcount, Qnil);
bindcount = -1;
}
return Fnreverse (allmatches);
}

View File

@ -3592,8 +3592,7 @@ system_process_attributes (Lisp_Object pid)
Vlocale_coding_system, 0);
attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs);
}
unbind_to (count, Qnil);
return attrs;
return unbind_to (count, attrs);
}
#elif defined __FreeBSD__

View File

@ -826,7 +826,7 @@ last valid position in OBJECT. */)
break;
}
unbind_to (count, Qnil);
position = unbind_to (count, position);
}
return position;
@ -920,7 +920,7 @@ first valid position in OBJECT. */)
}
}
unbind_to (count, Qnil);
position = unbind_to (count, position);
}
return position;

View File

@ -5771,8 +5771,7 @@ which see. */)
{
ptrdiff_t count = SPECPDL_INDEX ();
scroll_command (Fother_window_for_scrolling (), arg, 1);
unbind_to (count, Qnil);
return Qnil;
return unbind_to (count, Qnil);
}
DEFUN ("scroll-other-window-down", Fscroll_other_window_down,
@ -5783,8 +5782,7 @@ For more details, see the documentation for `scroll-other-window'. */)
{
ptrdiff_t count = SPECPDL_INDEX ();
scroll_command (Fother_window_for_scrolling (), arg, -1);
unbind_to (count, Qnil);
return Qnil;
return unbind_to (count, Qnil);
}
DEFUN ("scroll-left", Fscroll_left, Sscroll_left, 0, 2, "^P\np",

View File

@ -4937,7 +4937,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
specbind (Qposition, make_number (CHARPOS (*position)));
specbind (Qbuffer_position, make_number (bufpos));
form = safe_eval (form);
unbind_to (count, Qnil);
form = unbind_to (count, form);
}
if (NILP (form))
@ -5000,7 +5000,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]);
value = safe_eval (it->font_height);
unbind_to (count, Qnil);
value = unbind_to (count, value);
if (NUMBERP (value))
new_height = XFLOATINT (value);
@ -24183,8 +24183,7 @@ are the selected window and the WINDOW's buffer). */)
empty_unibyte_string);
}
unbind_to (count, Qnil);
return str;
return unbind_to (count, str);
}
/* Write a null-terminated, right justified decimal representation of
@ -24804,7 +24803,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
if (STRINGP (curdir))
val = call1 (intern ("file-remote-p"), curdir);
unbind_to (count, Qnil);
val = unbind_to (count, val);
if (NILP (val))
return "-";

View File

@ -387,7 +387,7 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
XCAR (XCDR (local_value)));
else
value = Qnil;
unbind_to (count, Qnil);
value = unbind_to (count, value);
}
/* Make sure this value is of a type that we could transmit