1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-05 11:45:45 +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: out:
unbind_to (gc_count, Qnil); return unbind_to (gc_count, found);
return found;
} }
#ifdef SUSPICIOUS_OBJECT_CHECKING #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; ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
Lisp_Object val; Lisp_Object val;
Lisp_Object undo_list = BVAR (current_buffer, undo_list); Lisp_Object undo_list = BVAR (current_buffer, undo_list);
ptrdiff_t count1 = SPECPDL_INDEX ();
record_unwind_protect (coding_restore_undo_list, record_unwind_protect (coding_restore_undo_list,
Fcons (undo_list, Fcurrent_buffer ())); Fcons (undo_list, Fcurrent_buffer ()));
@ -8016,7 +8015,6 @@ decode_coding_gap (struct coding_system *coding,
CHECK_NATNUM (val); CHECK_NATNUM (val);
coding->produced_char += Z - prev_Z; coding->produced_char += Z - prev_Z;
coding->produced += Z_BYTE - prev_Z_BYTE; coding->produced += Z_BYTE - prev_Z_BYTE;
unbind_to (count1, Qnil);
} }
unbind_to (count, Qnil); unbind_to (count, Qnil);
@ -8545,7 +8543,7 @@ are lower-case). */)
val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
Qt, Qnil, Qcoding_system_history, Qt, Qnil, Qcoding_system_history,
default_coding_system, Qnil); default_coding_system, Qnil);
unbind_to (count, Qnil); val = unbind_to (count, val);
return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
} }

View File

@ -5828,8 +5828,7 @@ immediately by pending input. */)
if (!NILP (force) && !redisplay_dont_pause) if (!NILP (force) && !redisplay_dont_pause)
specbind (Qredisplay_dont_pause, Qt); specbind (Qredisplay_dont_pause, Qt);
redisplay_preserve_echo_area (2); redisplay_preserve_echo_area (2);
unbind_to (count, Qnil); return unbind_to (count, Qt);
return 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); update_compositions (changed, last_changed, CHECK_ALL);
} }
unbind_to (count, Qnil); return unbind_to (count, Qnil);
return Qnil;
} }

View File

@ -2366,7 +2366,7 @@ eval_sub (Lisp_Object form)
specbind (Qlexical_binding, specbind (Qlexical_binding,
NILP (Vinternal_interpreter_environment) ? Qnil : Qt); NILP (Vinternal_interpreter_environment) ? Qnil : Qt);
exp = apply1 (Fcdr (fun), original_args); exp = apply1 (Fcdr (fun), original_args);
unbind_to (count1, Qnil); exp = unbind_to (count1, exp);
val = eval_sub (exp); val = eval_sub (exp);
} }
else if (EQ (funcar, Qlambda) 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; Vquit_flag = oquit;
/* This restores the message-stack status. */ /* This restores the message-stack status. */
unbind_to (count, Qnil); return unbind_to (count, Qnil);
return Qnil;
} }
DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved, 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); bidi_unshelve_cache (itdata, 0);
} }
unbind_to (count, Qnil); return unbind_to (count, make_number (it.vpos));
return make_number (it.vpos);
} }

View File

@ -1608,9 +1608,7 @@ like in the respective argument of `key-binding'. */)
keymaps = Fcons (otlp, keymaps); keymaps = Fcons (otlp, keymaps);
} }
unbind_to (count, Qnil); return unbind_to (count, keymaps);
return keymaps;
} }
/* GC is possible in this function if it autoloads a keymap. */ /* 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))); BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
readevalloop (buf, 0, filename, readevalloop (buf, 0, filename,
!NILP (printflag), unibyte, Qnil, Qnil, Qnil); !NILP (printflag), unibyte, Qnil, Qnil, Qnil);
unbind_to (count, Qnil); return unbind_to (count, Qnil);
return Qnil;
} }
DEFUN ("eval-region", Feval_region, Seval_region, 2, 4, "r", 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")); call0 (intern ("minibuffer-inactive-mode"));
else else
Fkill_all_local_variables (); Fkill_all_local_variables ();
unbind_to (count, Qnil); buf = unbind_to (count, buf);
} }
return buf; return buf;
@ -1274,11 +1274,12 @@ is used to further constrain the set of candidates. */)
for (regexps = Vcompletion_regexp_list; CONSP (regexps); for (regexps = Vcompletion_regexp_list; CONSP (regexps);
regexps = XCDR (regexps)) regexps = XCDR (regexps))
{ {
if (bindcount < 0) { if (bindcount < 0)
bindcount = SPECPDL_INDEX (); {
specbind (Qcase_fold_search, bindcount = SPECPDL_INDEX ();
completion_ignore_case ? Qt : Qnil); specbind (Qcase_fold_search,
} completion_ignore_case ? Qt : Qnil);
}
tem = Fstring_match (XCAR (regexps), eltstring, zero); tem = Fstring_match (XCAR (regexps), eltstring, zero);
if (NILP (tem)) if (NILP (tem))
break; break;
@ -1377,10 +1378,8 @@ is used to further constrain the set of candidates. */)
} }
} }
if (bindcount >= 0) { if (bindcount >= 0)
unbind_to (bindcount, Qnil); unbind_to (bindcount, Qnil);
bindcount = -1;
}
if (NILP (bestmatch)) if (NILP (bestmatch))
return Qnil; /* No completions found. */ 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); for (regexps = Vcompletion_regexp_list; CONSP (regexps);
regexps = XCDR (regexps)) regexps = XCDR (regexps))
{ {
if (bindcount < 0) { if (bindcount < 0)
bindcount = SPECPDL_INDEX (); {
specbind (Qcase_fold_search, bindcount = SPECPDL_INDEX ();
completion_ignore_case ? Qt : Qnil); specbind (Qcase_fold_search,
} completion_ignore_case ? Qt : Qnil);
}
tem = Fstring_match (XCAR (regexps), eltstring, zero); tem = Fstring_match (XCAR (regexps), eltstring, zero);
if (NILP (tem)) if (NILP (tem))
break; break;
@ -1556,10 +1556,11 @@ with a space are ignored unless STRING itself starts with a space. */)
tem = Fcommandp (elt, Qnil); tem = Fcommandp (elt, Qnil);
else else
{ {
if (bindcount >= 0) { if (bindcount >= 0)
unbind_to (bindcount, Qnil); {
bindcount = -1; unbind_to (bindcount, Qnil);
} bindcount = -1;
}
tem = type == 3 tem = type == 3
? call2 (predicate, elt, ? call2 (predicate, elt,
HASH_VALUE (XHASH_TABLE (collection), idx - 1)) 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); unbind_to (bindcount, Qnil);
bindcount = -1;
}
return Fnreverse (allmatches); return Fnreverse (allmatches);
} }

View File

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

View File

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

View File

@ -5771,8 +5771,7 @@ which see. */)
{ {
ptrdiff_t count = SPECPDL_INDEX (); ptrdiff_t count = SPECPDL_INDEX ();
scroll_command (Fother_window_for_scrolling (), arg, 1); scroll_command (Fother_window_for_scrolling (), arg, 1);
unbind_to (count, Qnil); return unbind_to (count, Qnil);
return Qnil;
} }
DEFUN ("scroll-other-window-down", Fscroll_other_window_down, 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 (); ptrdiff_t count = SPECPDL_INDEX ();
scroll_command (Fother_window_for_scrolling (), arg, -1); scroll_command (Fother_window_for_scrolling (), arg, -1);
unbind_to (count, Qnil); return unbind_to (count, Qnil);
return Qnil;
} }
DEFUN ("scroll-left", Fscroll_left, Sscroll_left, 0, 2, "^P\np", 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 (Qposition, make_number (CHARPOS (*position)));
specbind (Qbuffer_position, make_number (bufpos)); specbind (Qbuffer_position, make_number (bufpos));
form = safe_eval (form); form = safe_eval (form);
unbind_to (count, Qnil); form = unbind_to (count, form);
} }
if (NILP (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]); specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]);
value = safe_eval (it->font_height); value = safe_eval (it->font_height);
unbind_to (count, Qnil); value = unbind_to (count, value);
if (NUMBERP (value)) if (NUMBERP (value))
new_height = XFLOATINT (value); new_height = XFLOATINT (value);
@ -24183,8 +24183,7 @@ are the selected window and the WINDOW's buffer). */)
empty_unibyte_string); empty_unibyte_string);
} }
unbind_to (count, Qnil); return unbind_to (count, str);
return str;
} }
/* Write a null-terminated, right justified decimal representation of /* 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)) if (STRINGP (curdir))
val = call1 (intern ("file-remote-p"), curdir); val = call1 (intern ("file-remote-p"), curdir);
unbind_to (count, Qnil); val = unbind_to (count, val);
if (NILP (val)) if (NILP (val))
return "-"; return "-";

View File

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