[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a8b713d83a 14/14: Inline maybe_quit
From: |
Mattias Engdegård |
Subject: |
master a8b713d83a 14/14: Inline maybe_quit |
Date: |
Mon, 24 Jan 2022 05:42:37 -0500 (EST) |
branch: master
commit a8b713d83a5544d144c05aa45c465bbe3ebc8789
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Inline maybe_quit
Since `maybe_quit` is called on many critical paths, inline a slightly
cheaper condition (that ignores Vinhibit_quit).
* src/eval.c (maybe_quit): Rename to `probably_quit`.
* src/lisp.h (maybe_quit): New simplified inline function.
---
src/ccl.c | 1 +
src/eval.c | 15 +--------------
src/lisp.h | 26 ++++++++++++++++++++++++--
3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/ccl.c b/src/ccl.c
index 377eb3a0ea..a3121f7278 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -33,6 +33,7 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
#include "charset.h"
#include "ccl.h"
#include "coding.h"
+#include "keyboard.h"
/* Table of registered CCL programs. Each element is a vector of
NAME, CCL_PROG, RESOLVEDP, and UPDATEDP, where NAME (symbol) is the
diff --git a/src/eval.c b/src/eval.c
index 744fe82347..205a0b0db2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1737,21 +1737,8 @@ process_quit_flag (void)
quit ();
}
-/* Check quit-flag and quit if it is non-nil. Typing C-g does not
- directly cause a quit; it only sets Vquit_flag. So the program
- needs to call maybe_quit at times when it is safe to quit. Every
- loop that might run for a long time or might not exit ought to call
- maybe_quit at least once, at a safe place. Unless that is
- impossible, of course. But it is very desirable to avoid creating
- loops where maybe_quit is impossible.
-
- If quit-flag is set to `kill-emacs' the SIGINT handler has received
- a request to exit Emacs when it is safe to do.
-
- When not quitting, process any pending signals. */
-
void
-maybe_quit (void)
+probably_quit (void)
{
if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
process_quit_flag ();
diff --git a/src/lisp.h b/src/lisp.h
index 54e8c30ccf..9f1d093f58 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3422,12 +3422,34 @@ struct handler
extern Lisp_Object memory_signal_data;
-extern void maybe_quit (void);
-
/* True if ought to quit now. */
#define QUITP (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
+extern bool volatile pending_signals;
+extern void process_pending_signals (void);
+extern void probably_quit (void);
+
+/* Check quit-flag and quit if it is non-nil. Typing C-g does not
+ directly cause a quit; it only sets Vquit_flag. So the program
+ needs to call maybe_quit at times when it is safe to quit. Every
+ loop that might run for a long time or might not exit ought to call
+ maybe_quit at least once, at a safe place. Unless that is
+ impossible, of course. But it is very desirable to avoid creating
+ loops where maybe_quit is impossible.
+
+ If quit-flag is set to `kill-emacs' the SIGINT handler has received
+ a request to exit Emacs when it is safe to do.
+
+ When not quitting, process any pending signals. */
+
+INLINE void
+maybe_quit (void)
+{
+ if (!NILP (Vquit_flag) || pending_signals)
+ probably_quit ();
+}
+
/* Process a quit rarely, based on a counter COUNT, for efficiency.
"Rarely" means once per USHRT_MAX + 1 times; this is somewhat
arbitrary, but efficient. */
- master 65caf5b205 04/14: Pin bytecode strings to avoid copy at call time, (continued)
- master 65caf5b205 04/14: Pin bytecode strings to avoid copy at call time, Mattias Engdegård, 2022/01/24
- master 7392f2dc41 05/14: Byte code arity check micro-optimisation, Mattias Engdegård, 2022/01/24
- master 4a0541a5dd 12/14: Implement Ffuncall in terms of funcall_general, Mattias Engdegård, 2022/01/24
- master b3377e67a7 07/14: Remove nil check in exec_byte_code, Mattias Engdegård, 2022/01/24
- master 4ff1fb8eb4 08/14: Move a runtime interpreter check to debug mode, Mattias Engdegård, 2022/01/24
- master 11e1abd5cc 10/14: Open-code aref and aset in bytecode interpreter, Mattias Engdegård, 2022/01/24
- master 721357b868 09/14: Remove the unused unbind-all bytecode, Mattias Engdegård, 2022/01/24
- master d05f387407 06/14: ; * src/bytecode.c (exec_byte_code): Cosmetic improvement, Mattias Engdegård, 2022/01/24
- master 75c6564c92 11/14: ; * lisp/emacs-lisp/byte-opt.el: Remove outdated comments, Mattias Engdegård, 2022/01/24
- master b7902a9b48 13/14: Bump specpdl inline, move reallocation out of line, Mattias Engdegård, 2022/01/24
- master a8b713d83a 14/14: Inline maybe_quit,
Mattias Engdegård <=
- Re: master updated (bcf844b5fc -> a8b713d83a), Lars Ingebrigtsen, 2022/01/24