diff options
author | Po Lu <luangruo@yahoo.com> | 2022-10-15 16:25:22 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-10-15 16:25:22 +0800 |
commit | a06c54209499c3885c13a8d3eba7798ab3f0d688 (patch) | |
tree | 6474747e490bd203b3136a70e8b3d225eb033522 /src/xterm.c | |
parent | e185526d216e544a70b2be77b34b5cb5386762d1 (diff) | |
download | emacs-a06c54209499c3885c13a8d3eba7798ab3f0d688.tar.gz |
Remove redundant call to expensive function XOpenDisplay
* src/xterm.c (x_term_init): Speed up opening Emacs over a slow
network connection by an order of magnitude on no toolkit builds
by avoiding a redundant call to XOpenDisplay.
Diffstat (limited to 'src/xterm.c')
-rw-r--r-- | src/xterm.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/xterm.c b/src/xterm.c index 0fca9788ce5..d35af7a8de2 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -28527,9 +28527,10 @@ xi_check_toolkit (Display *display) #endif -/* Open a connection to X display DISPLAY_NAME, and return - the structure that describes the open display. - If we cannot contact the display, return null. */ +/* Open a connection to X display DISPLAY_NAME, and return the + structure that describes the open display. If obtaining the XCB + connection or toolkit-specific display fails, return NULL. Signal + an error if opening the display itself failed. */ struct x_display_info * x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) @@ -28556,9 +28557,13 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) ++x_initialized; } - if (! x_display_ok (SSDATA (display_name))) +#if defined USE_X_TOOLKIT || defined USE_GTK + + if (!x_display_ok (SSDATA (display_name))) error ("Display %s can't be opened", SSDATA (display_name)); +#endif + #ifdef USE_GTK { #define NUM_ARGV 10 @@ -28685,6 +28690,15 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) /* Detect failure. */ if (dpy == 0) { +#if !defined USE_X_TOOLKIT && !defined USE_GTK + /* Avoid opening a display three times (once in dispextern.c + upon startup, once in x_display_ok, and once above) to + determine whether or not the display is alive on no toolkit + builds, where no toolkit initialization happens at all. */ + + error ("Display %s can't be opened", SSDATA (display_name)); +#endif + unblock_input (); return 0; } |