]> git.eshelyaron.com Git - emacs.git/commitdiff
; * src/xterm.c (x_if_event): Minor speed improvements.
authorPo Lu <luangruo@yahoo.com>
Wed, 3 Aug 2022 12:17:18 +0000 (20:17 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 3 Aug 2022 12:17:31 +0000 (20:17 +0800)
src/xterm.c

index eb1a557e88394950c7b90b68eff2327650055739..f82340958e5250c7eb68a39a22da3c9b57b023b0 100644 (file)
@@ -6605,12 +6605,17 @@ x_if_event (Display *dpy, XEvent *event_return,
   current_time = current_timespec ();
   target = timespec_add (current_time, timeout);
 
+  /* Check if an event is already in the queue.  If it is, avoid
+     syncing.  */
+  if (XCheckIfEvent (dpy, event_return, predicate, arg))
+    return 0;
+
   while (true)
     {
       /* Get events into the queue.  */
       XSync (dpy, False);
 
-      /* Check if an event is now in the queue.  */
+      /* Look for an event again.  */
       if (XCheckIfEvent (dpy, event_return, predicate, arg))
        return 0;