aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-06-29 17:07:38 -0700
committerPaul Eggert2018-06-29 17:07:57 -0700
commit2e2811865f0adb6658a87d3581a2dc3a9022f451 (patch)
tree286e80914dc979a45070be1929faad22a618eb7c /src
parent08594a975a3d95b1c1eae38af608e487e2edfafc (diff)
downloademacs-2e2811865f0adb6658a87d3581a2dc3a9022f451.tar.gz
emacs-2e2811865f0adb6658a87d3581a2dc3a9022f451.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c3
-rw-r--r--src/coding.c4
-rw-r--r--src/dispnew.c3
-rw-r--r--src/editfns.c3
-rw-r--r--src/eval.c2
-rw-r--r--src/fileio.c3
-rw-r--r--src/indent.c4
-rw-r--r--src/keymap.c4
-rw-r--r--src/lread.c4
-rw-r--r--src/minibuf.c41
-rw-r--r--src/sysdep.c3
-rw-r--r--src/textprop.c4
-rw-r--r--src/window.c6
-rw-r--r--src/xdisp.c9
-rw-r--r--src/xselect.c2
15 files changed, 39 insertions, 56 deletions
diff --git a/src/alloc.c b/src/alloc.c
index cc846fd38ee..8764591336e 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -7206,8 +7206,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
7206 } 7206 }
7207 7207
7208 out: 7208 out:
7209 unbind_to (gc_count, Qnil); 7209 return unbind_to (gc_count, found);
7210 return found;
7211} 7210}
7212 7211
7213#ifdef SUSPICIOUS_OBJECT_CHECKING 7212#ifdef SUSPICIOUS_OBJECT_CHECKING
diff --git a/src/coding.c b/src/coding.c
index 32a9df1c533..8ce902b06d5 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -8005,7 +8005,6 @@ decode_coding_gap (struct coding_system *coding,
8005 ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; 8005 ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
8006 Lisp_Object val; 8006 Lisp_Object val;
8007 Lisp_Object undo_list = BVAR (current_buffer, undo_list); 8007 Lisp_Object undo_list = BVAR (current_buffer, undo_list);
8008 ptrdiff_t count1 = SPECPDL_INDEX ();
8009 8008
8010 record_unwind_protect (coding_restore_undo_list, 8009 record_unwind_protect (coding_restore_undo_list,
8011 Fcons (undo_list, Fcurrent_buffer ())); 8010 Fcons (undo_list, Fcurrent_buffer ()));
@@ -8016,7 +8015,6 @@ decode_coding_gap (struct coding_system *coding,
8016 CHECK_NATNUM (val); 8015 CHECK_NATNUM (val);
8017 coding->produced_char += Z - prev_Z; 8016 coding->produced_char += Z - prev_Z;
8018 coding->produced += Z_BYTE - prev_Z_BYTE; 8017 coding->produced += Z_BYTE - prev_Z_BYTE;
8019 unbind_to (count1, Qnil);
8020 } 8018 }
8021 8019
8022 unbind_to (count, Qnil); 8020 unbind_to (count, Qnil);
@@ -8545,7 +8543,7 @@ are lower-case). */)
8545 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil, 8543 val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
8546 Qt, Qnil, Qcoding_system_history, 8544 Qt, Qnil, Qcoding_system_history,
8547 default_coding_system, Qnil); 8545 default_coding_system, Qnil);
8548 unbind_to (count, Qnil); 8546 val = unbind_to (count, val);
8549 return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); 8547 return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
8550} 8548}
8551 8549
diff --git a/src/dispnew.c b/src/dispnew.c
index 46e0c83ef6a..fc6f9e22632 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5828,8 +5828,7 @@ immediately by pending input. */)
5828 if (!NILP (force) && !redisplay_dont_pause) 5828 if (!NILP (force) && !redisplay_dont_pause)
5829 specbind (Qredisplay_dont_pause, Qt); 5829 specbind (Qredisplay_dont_pause, Qt);
5830 redisplay_preserve_echo_area (2); 5830 redisplay_preserve_echo_area (2);
5831 unbind_to (count, Qnil); 5831 return unbind_to (count, Qt);
5832 return Qt;
5833} 5832}
5834 5833
5835 5834
diff --git a/src/editfns.c b/src/editfns.c
index 88dfba1f910..efe83e811ba 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3531,8 +3531,7 @@ Both characters must have the same length of multi-byte form. */)
3531 update_compositions (changed, last_changed, CHECK_ALL); 3531 update_compositions (changed, last_changed, CHECK_ALL);
3532 } 3532 }
3533 3533
3534 unbind_to (count, Qnil); 3534 return unbind_to (count, Qnil);
3535 return Qnil;
3536} 3535}
3537 3536
3538 3537
diff --git a/src/eval.c b/src/eval.c
index 9e0fabdcfba..c16a267bc5e 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2366,7 +2366,7 @@ eval_sub (Lisp_Object form)
2366 specbind (Qlexical_binding, 2366 specbind (Qlexical_binding,
2367 NILP (Vinternal_interpreter_environment) ? Qnil : Qt); 2367 NILP (Vinternal_interpreter_environment) ? Qnil : Qt);
2368 exp = apply1 (Fcdr (fun), original_args); 2368 exp = apply1 (Fcdr (fun), original_args);
2369 unbind_to (count1, Qnil); 2369 exp = unbind_to (count1, exp);
2370 val = eval_sub (exp); 2370 val = eval_sub (exp);
2371 } 2371 }
2372 else if (EQ (funcar, Qlambda) 2372 else if (EQ (funcar, Qlambda)
diff --git a/src/fileio.c b/src/fileio.c
index 7f678dd8216..5a1c7ae10e5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5767,8 +5767,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5767 Vquit_flag = oquit; 5767 Vquit_flag = oquit;
5768 5768
5769 /* This restores the message-stack status. */ 5769 /* This restores the message-stack status. */
5770 unbind_to (count, Qnil); 5770 return unbind_to (count, Qnil);
5771 return Qnil;
5772} 5771}
5773 5772
5774DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved, 5773DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved,
diff --git a/src/indent.c b/src/indent.c
index 9c751bc30b5..a86db71642e 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2356,9 +2356,7 @@ whether or not it is currently displayed in some window. */)
2356 bidi_unshelve_cache (itdata, 0); 2356 bidi_unshelve_cache (itdata, 0);
2357 } 2357 }
2358 2358
2359 unbind_to (count, Qnil); 2359 return unbind_to (count, make_number (it.vpos));
2360
2361 return make_number (it.vpos);
2362} 2360}
2363 2361
2364 2362
diff --git a/src/keymap.c b/src/keymap.c
index 982c014f01f..fcee788e6f9 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1608,9 +1608,7 @@ like in the respective argument of `key-binding'. */)
1608 keymaps = Fcons (otlp, keymaps); 1608 keymaps = Fcons (otlp, keymaps);
1609 } 1609 }
1610 1610
1611 unbind_to (count, Qnil); 1611 return unbind_to (count, keymaps);
1612
1613 return keymaps;
1614} 1612}
1615 1613
1616/* GC is possible in this function if it autoloads a keymap. */ 1614/* GC is possible in this function if it autoloads a keymap. */
diff --git a/src/lread.c b/src/lread.c
index 4229ff568be..d4e5be21b4b 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2143,9 +2143,7 @@ This function preserves the position of point. */)
2143 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); 2143 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
2144 readevalloop (buf, 0, filename, 2144 readevalloop (buf, 0, filename,
2145 !NILP (printflag), unibyte, Qnil, Qnil, Qnil); 2145 !NILP (printflag), unibyte, Qnil, Qnil, Qnil);
2146 unbind_to (count, Qnil); 2146 return unbind_to (count, Qnil);
2147
2148 return Qnil;
2149} 2147}
2150 2148
2151DEFUN ("eval-region", Feval_region, Seval_region, 2, 4, "r", 2149DEFUN ("eval-region", Feval_region, Seval_region, 2, 4, "r",
diff --git a/src/minibuf.c b/src/minibuf.c
index e18c99bef28..abc48663802 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -755,7 +755,7 @@ get_minibuffer (EMACS_INT depth)
755 call0 (intern ("minibuffer-inactive-mode")); 755 call0 (intern ("minibuffer-inactive-mode"));
756 else 756 else
757 Fkill_all_local_variables (); 757 Fkill_all_local_variables ();
758 unbind_to (count, Qnil); 758 buf = unbind_to (count, buf);
759 } 759 }
760 760
761 return buf; 761 return buf;
@@ -1274,11 +1274,12 @@ is used to further constrain the set of candidates. */)
1274 for (regexps = Vcompletion_regexp_list; CONSP (regexps); 1274 for (regexps = Vcompletion_regexp_list; CONSP (regexps);
1275 regexps = XCDR (regexps)) 1275 regexps = XCDR (regexps))
1276 { 1276 {
1277 if (bindcount < 0) { 1277 if (bindcount < 0)
1278 bindcount = SPECPDL_INDEX (); 1278 {
1279 specbind (Qcase_fold_search, 1279 bindcount = SPECPDL_INDEX ();
1280 completion_ignore_case ? Qt : Qnil); 1280 specbind (Qcase_fold_search,
1281 } 1281 completion_ignore_case ? Qt : Qnil);
1282 }
1282 tem = Fstring_match (XCAR (regexps), eltstring, zero); 1283 tem = Fstring_match (XCAR (regexps), eltstring, zero);
1283 if (NILP (tem)) 1284 if (NILP (tem))
1284 break; 1285 break;
@@ -1377,10 +1378,8 @@ is used to further constrain the set of candidates. */)
1377 } 1378 }
1378 } 1379 }
1379 1380
1380 if (bindcount >= 0) { 1381 if (bindcount >= 0)
1381 unbind_to (bindcount, Qnil); 1382 unbind_to (bindcount, Qnil);
1382 bindcount = -1;
1383 }
1384 1383
1385 if (NILP (bestmatch)) 1384 if (NILP (bestmatch))
1386 return Qnil; /* No completions found. */ 1385 return Qnil; /* No completions found. */
@@ -1534,11 +1533,12 @@ with a space are ignored unless STRING itself starts with a space. */)
1534 for (regexps = Vcompletion_regexp_list; CONSP (regexps); 1533 for (regexps = Vcompletion_regexp_list; CONSP (regexps);
1535 regexps = XCDR (regexps)) 1534 regexps = XCDR (regexps))
1536 { 1535 {
1537 if (bindcount < 0) { 1536 if (bindcount < 0)
1538 bindcount = SPECPDL_INDEX (); 1537 {
1539 specbind (Qcase_fold_search, 1538 bindcount = SPECPDL_INDEX ();
1540 completion_ignore_case ? Qt : Qnil); 1539 specbind (Qcase_fold_search,
1541 } 1540 completion_ignore_case ? Qt : Qnil);
1541 }
1542 tem = Fstring_match (XCAR (regexps), eltstring, zero); 1542 tem = Fstring_match (XCAR (regexps), eltstring, zero);
1543 if (NILP (tem)) 1543 if (NILP (tem))
1544 break; 1544 break;
@@ -1556,10 +1556,11 @@ with a space are ignored unless STRING itself starts with a space. */)
1556 tem = Fcommandp (elt, Qnil); 1556 tem = Fcommandp (elt, Qnil);
1557 else 1557 else
1558 { 1558 {
1559 if (bindcount >= 0) { 1559 if (bindcount >= 0)
1560 unbind_to (bindcount, Qnil); 1560 {
1561 bindcount = -1; 1561 unbind_to (bindcount, Qnil);
1562 } 1562 bindcount = -1;
1563 }
1563 tem = type == 3 1564 tem = type == 3
1564 ? call2 (predicate, elt, 1565 ? call2 (predicate, elt,
1565 HASH_VALUE (XHASH_TABLE (collection), idx - 1)) 1566 HASH_VALUE (XHASH_TABLE (collection), idx - 1))
@@ -1572,10 +1573,8 @@ with a space are ignored unless STRING itself starts with a space. */)
1572 } 1573 }
1573 } 1574 }
1574 1575
1575 if (bindcount >= 0) { 1576 if (bindcount >= 0)
1576 unbind_to (bindcount, Qnil); 1577 unbind_to (bindcount, Qnil);
1577 bindcount = -1;
1578 }
1579 1578
1580 return Fnreverse (allmatches); 1579 return Fnreverse (allmatches);
1581} 1580}
diff --git a/src/sysdep.c b/src/sysdep.c
index c59034ce5c3..231b11614f4 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3592,8 +3592,7 @@ system_process_attributes (Lisp_Object pid)
3592 Vlocale_coding_system, 0); 3592 Vlocale_coding_system, 0);
3593 attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs); 3593 attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs);
3594 } 3594 }
3595 unbind_to (count, Qnil); 3595 return unbind_to (count, attrs);
3596 return attrs;
3597} 3596}
3598 3597
3599#elif defined __FreeBSD__ 3598#elif defined __FreeBSD__
diff --git a/src/textprop.c b/src/textprop.c
index 984f2e66406..f7e69f30ea6 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -826,7 +826,7 @@ last valid position in OBJECT. */)
826 break; 826 break;
827 } 827 }
828 828
829 unbind_to (count, Qnil); 829 position = unbind_to (count, position);
830 } 830 }
831 831
832 return position; 832 return position;
@@ -920,7 +920,7 @@ first valid position in OBJECT. */)
920 } 920 }
921 } 921 }
922 922
923 unbind_to (count, Qnil); 923 position = unbind_to (count, position);
924 } 924 }
925 925
926 return position; 926 return position;
diff --git a/src/window.c b/src/window.c
index 81fd7f2b477..a97f1dd3efb 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5771,8 +5771,7 @@ which see. */)
5771{ 5771{
5772 ptrdiff_t count = SPECPDL_INDEX (); 5772 ptrdiff_t count = SPECPDL_INDEX ();
5773 scroll_command (Fother_window_for_scrolling (), arg, 1); 5773 scroll_command (Fother_window_for_scrolling (), arg, 1);
5774 unbind_to (count, Qnil); 5774 return unbind_to (count, Qnil);
5775 return Qnil;
5776} 5775}
5777 5776
5778DEFUN ("scroll-other-window-down", Fscroll_other_window_down, 5777DEFUN ("scroll-other-window-down", Fscroll_other_window_down,
@@ -5783,8 +5782,7 @@ For more details, see the documentation for `scroll-other-window'. */)
5783{ 5782{
5784 ptrdiff_t count = SPECPDL_INDEX (); 5783 ptrdiff_t count = SPECPDL_INDEX ();
5785 scroll_command (Fother_window_for_scrolling (), arg, -1); 5784 scroll_command (Fother_window_for_scrolling (), arg, -1);
5786 unbind_to (count, Qnil); 5785 return unbind_to (count, Qnil);
5787 return Qnil;
5788} 5786}
5789 5787
5790DEFUN ("scroll-left", Fscroll_left, Sscroll_left, 0, 2, "^P\np", 5788DEFUN ("scroll-left", Fscroll_left, Sscroll_left, 0, 2, "^P\np",
diff --git a/src/xdisp.c b/src/xdisp.c
index 3406c2fb466..e383b3b0d16 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -4937,7 +4937,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4937 specbind (Qposition, make_number (CHARPOS (*position))); 4937 specbind (Qposition, make_number (CHARPOS (*position)));
4938 specbind (Qbuffer_position, make_number (bufpos)); 4938 specbind (Qbuffer_position, make_number (bufpos));
4939 form = safe_eval (form); 4939 form = safe_eval (form);
4940 unbind_to (count, Qnil); 4940 form = unbind_to (count, form);
4941 } 4941 }
4942 4942
4943 if (NILP (form)) 4943 if (NILP (form))
@@ -5000,7 +5000,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5000 5000
5001 specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]); 5001 specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]);
5002 value = safe_eval (it->font_height); 5002 value = safe_eval (it->font_height);
5003 unbind_to (count, Qnil); 5003 value = unbind_to (count, value);
5004 5004
5005 if (NUMBERP (value)) 5005 if (NUMBERP (value))
5006 new_height = XFLOATINT (value); 5006 new_height = XFLOATINT (value);
@@ -24183,8 +24183,7 @@ are the selected window and the WINDOW's buffer). */)
24183 empty_unibyte_string); 24183 empty_unibyte_string);
24184 } 24184 }
24185 24185
24186 unbind_to (count, Qnil); 24186 return unbind_to (count, str);
24187 return str;
24188} 24187}
24189 24188
24190/* Write a null-terminated, right justified decimal representation of 24189/* 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,
24804 if (STRINGP (curdir)) 24803 if (STRINGP (curdir))
24805 val = call1 (intern ("file-remote-p"), curdir); 24804 val = call1 (intern ("file-remote-p"), curdir);
24806 24805
24807 unbind_to (count, Qnil); 24806 val = unbind_to (count, val);
24808 24807
24809 if (NILP (val)) 24808 if (NILP (val))
24810 return "-"; 24809 return "-";
diff --git a/src/xselect.c b/src/xselect.c
index ecf59df2943..1f51be4c522 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -387,7 +387,7 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
387 XCAR (XCDR (local_value))); 387 XCAR (XCDR (local_value)));
388 else 388 else
389 value = Qnil; 389 value = Qnil;
390 unbind_to (count, Qnil); 390 value = unbind_to (count, value);
391 } 391 }
392 392
393 /* Make sure this value is of a type that we could transmit 393 /* Make sure this value is of a type that we could transmit