From 3de717bdb483f7c6e23cd7701ee4ebd77eccb8b9 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 7 Mar 2013 07:01:17 +0400 Subject: [PATCH] * lisp.h (list2i, list3i): New functions. (list4i): Move from window.c and make LISP_INLINE. * editfns.c (make_lisp_time): * fns.c (Flocale_info): * keyboard.c (parse_modifiers): * xterm.c (x_ewmh_activate_frame): Use list2i. * instel.c (signal_after_change): * nsfns.m (Fx_server_version, Fxw_color_values): * w32fns.c (Fxw_color_values, Fx_server_version): * xfns.c (Fxw_color_values, Fx_server_version): Use list3i. * fileio.c (Fvisited_file_modtime): * nsfns.m (Fns_display_usable_bounds): * w32.c (ltime): Use list4i. --- src/ChangeLog | 16 ++++++++++++++++ src/editfns.c | 4 +--- src/fileio.c | 3 +-- src/fns.c | 5 +---- src/insdel.c | 5 ++--- src/keyboard.c | 4 +--- src/lisp.h | 22 ++++++++++++++++++++++ src/nsfns.m | 18 +++++++----------- src/w32.c | 6 ++---- src/w32fns.c | 13 ++++--------- src/window.c | 9 --------- src/xfns.c | 9 +++------ src/xterm.c | 5 +---- 13 files changed, 61 insertions(+), 58 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c54d4bee7e9..eee20d998dd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +2013-03-07 Dmitry Antipov + + * lisp.h (list2i, list3i): New functions. + (list4i): Move from window.c and make LISP_INLINE. + * editfns.c (make_lisp_time): + * fns.c (Flocale_info): + * keyboard.c (parse_modifiers): + * xterm.c (x_ewmh_activate_frame): Use list2i. + * instel.c (signal_after_change): + * nsfns.m (Fx_server_version, Fxw_color_values): + * w32fns.c (Fxw_color_values, Fx_server_version): + * xfns.c (Fxw_color_values, Fx_server_version): Use list3i. + * fileio.c (Fvisited_file_modtime): + * nsfns.m (Fns_display_usable_bounds): + * w32.c (ltime): Use list4i. + 2013-03-06 Eli Zaretskii * search.c (find_newline_no_quit): Rename from find_next_newline. diff --git a/src/editfns.c b/src/editfns.c index 831c8359fab..e1813dc65a1 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -1484,9 +1484,7 @@ Lisp_Object make_lisp_time (EMACS_TIME t) { int ns = EMACS_NSECS (t); - return make_time_tail (EMACS_SECS (t), - list2 (make_number (ns / 1000), - make_number (ns % 1000 * 1000))); + return make_time_tail (EMACS_SECS (t), list2i (ns / 1000, ns % 1000 * 1000)); } /* Decode a Lisp list SPECIFIED_TIME that represents a time. diff --git a/src/fileio.c b/src/fileio.c index 89ad3396464..d7363077b35 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5413,8 +5413,7 @@ See Info node `(elisp)Modification Time' for more details. */) if (EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS) { /* make_lisp_time won't work here if time_t is unsigned. */ - return list4 (make_number (-1), make_number (65535), - make_number (0), make_number (0)); + return list4i (-1, 65535, 0, 0); } return make_number (0); } diff --git a/src/fns.c b/src/fns.c index 44ddf340856..b3a1dc2317a 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2839,10 +2839,7 @@ The data read from the system are decoded using `locale-coding-system'. */) but is in the locale files. This could be used by ps-print. */ #ifdef PAPER_WIDTH else if (EQ (item, Qpaper)) - { - return list2 (make_number (nl_langinfo (PAPER_WIDTH)), - make_number (nl_langinfo (PAPER_HEIGHT))); - } + return list2i (nl_langinfo (PAPER_WIDTH), nl_langinfo (PAPER_HEIGHT)); #endif /* PAPER_WIDTH */ #endif /* HAVE_LANGINFO_CODESET*/ return Qnil; diff --git a/src/insdel.c b/src/insdel.c index 4cf4e6452a1..fc5a4576dc2 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -2013,9 +2013,8 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins) && current_buffer != XBUFFER (combine_after_change_buffer)) Fcombine_after_change_execute (); - elt = Fcons (make_number (charpos - BEG), - Fcons (make_number (Z - (charpos - lendel + lenins)), - Fcons (make_number (lenins - lendel), Qnil))); + elt = list3i (charpos - BEG, Z - (charpos - lendel + lenins), + lenins - lendel); combine_after_change_list = Fcons (elt, combine_after_change_list); combine_after_change_buffer = Fcurrent_buffer (); diff --git a/src/keyboard.c b/src/keyboard.c index 9cb9dd0b47b..914378947ed 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6225,9 +6225,7 @@ parse_modifiers (Lisp_Object symbol) Lisp_Object elements; if (INTEGERP (symbol)) - return (Fcons (make_number (KEY_TO_CHAR (symbol)), - Fcons (make_number (XINT (symbol) & CHAR_MODIFIER_MASK), - Qnil))); + return list2i (KEY_TO_CHAR (symbol), XINT (symbol) & CHAR_MODIFIER_MASK); else if (!SYMBOLP (symbol)) return Qnil; diff --git a/src/lisp.h b/src/lisp.h index fe216b93401..72bf4223d6b 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3001,6 +3001,28 @@ extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); enum constype {CONSTYPE_HEAP, CONSTYPE_PURE}; extern Lisp_Object listn (enum constype, ptrdiff_t, Lisp_Object, ...); + +/* Build a frequently used 2/3/4-integer lists. */ + +LISP_INLINE Lisp_Object +list2i (EMACS_INT x, EMACS_INT y) +{ + return list2 (make_number (x), make_number (y)); +} + +LISP_INLINE Lisp_Object +list3i (EMACS_INT x, EMACS_INT y, EMACS_INT w) +{ + return list3 (make_number (x), make_number (y), make_number (w)); +} + +LISP_INLINE Lisp_Object +list4i (EMACS_INT x, EMACS_INT y, EMACS_INT w, EMACS_INT h) +{ + return list4 (make_number (x), make_number (y), + make_number (w), make_number (h)); +} + extern _Noreturn void string_overflow (void); extern Lisp_Object make_string (const char *, ptrdiff_t); extern Lisp_Object make_formatted_string (char *, const char *, ...) diff --git a/src/nsfns.m b/src/nsfns.m index fac61d2ab53..e4dde5fb894 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1649,9 +1649,7 @@ If omitted or nil, that stands for the selected frame's display. */) The last number is where we distinguish between the Apple and GNUstep implementations ("distributor-specific release number") and give int'ized versions of major.minor. */ - return Fcons (make_number (10), - Fcons (make_number (3), - Fcons (make_number (ns_appkit_version_int()), Qnil))); + return list3i (10, 3, ns_appkit_version_int ()); } @@ -2296,9 +2294,8 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, [[col colorUsingColorSpaceName: NSCalibratedRGBColorSpace] getRed: &red green: &green blue: &blue alpha: &alpha]; - return list3 (make_number (lrint (red*65280)), - make_number (lrint (green*65280)), - make_number (lrint (blue*65280))); + return list3i (lrint (red * 65280), lrint (green * 65280), + lrint (blue * 65280)); } @@ -2385,11 +2382,10 @@ that stands for the selected frame's display. */) /* NS coordinate system is upside-down. Transform to screen-specific coordinates. */ - return list4 (make_number ((int) vScreen.origin.x), - make_number ((int) [screen frame].size.height - - vScreen.size.height - vScreen.origin.y), - make_number ((int) vScreen.size.width), - make_number ((int) vScreen.size.height)); + return list4i (vScreen.origin.x, + [screen frame].size.height + - vScreen.size.height - vScreen.origin.y, + vScreen.size.width, vScreen.size.height); } diff --git a/src/w32.c b/src/w32.c index 5a6cb894f5f..647faf94ef1 100644 --- a/src/w32.c +++ b/src/w32.c @@ -5580,10 +5580,8 @@ ltime (ULONGLONG time_100ns) { ULONGLONG time_sec = time_100ns / 10000000; int subsec = time_100ns % 10000000; - return list4 (make_number (time_sec >> 16), - make_number (time_sec & 0xffff), - make_number (subsec / 10), - make_number (subsec % 10 * 100000)); + return list4i (time_sec >> 16, time_sec & 0xffff, + subsec / 10, subsec % 10 * 100000); } #define U64_TO_LISP_TIME(time) ltime (time) diff --git a/src/w32fns.c b/src/w32fns.c index 5fab2c9a3df..6fd980c6b70 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -4587,12 +4587,9 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, CHECK_STRING (color); if (w32_defined_color (f, SDATA (color), &foo, 0)) - return list3 (make_number ((GetRValue (foo.pixel) << 8) - | GetRValue (foo.pixel)), - make_number ((GetGValue (foo.pixel) << 8) - | GetGValue (foo.pixel)), - make_number ((GetBValue (foo.pixel) << 8) - | GetBValue (foo.pixel))); + return list3i ((GetRValue (foo.pixel) << 8) | GetRValue (foo.pixel), + (GetGValue (foo.pixel) << 8) | GetGValue (foo.pixel), + (GetBValue (foo.pixel) << 8) | GetBValue (foo.pixel)); else return Qnil; } @@ -4718,9 +4715,7 @@ DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) (Lisp_Object display) { - return Fcons (make_number (w32_major_version), - Fcons (make_number (w32_minor_version), - Fcons (make_number (w32_build_number), Qnil))); + return list3i (w32_major_version, w32_minor_version, w32_build_number); } DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, diff --git a/src/window.c b/src/window.c index c2da2e8637a..ed0c1283abe 100644 --- a/src/window.c +++ b/src/window.c @@ -300,15 +300,6 @@ wset_buffer (struct window *w, Lisp_Object val) adjust_window_count (w, 1); } -/* Build a frequently used 4-integer (X Y W H) list. */ - -static Lisp_Object -list4i (EMACS_INT x, EMACS_INT y, EMACS_INT w, EMACS_INT h) -{ - return list4 (make_number (x), make_number (y), - make_number (w), make_number (h)); -} - DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, doc: /* Return t if OBJECT is a window and nil otherwise. */) (Lisp_Object object) diff --git a/src/xfns.c b/src/xfns.c index f01983fea4d..5c93b8ef4da 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -3539,9 +3539,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, CHECK_STRING (color); if (x_defined_color (f, SSDATA (color), &foo, 0)) - return list3 (make_number (foo.red), - make_number (foo.green), - make_number (foo.blue)); + return list3i (foo.red, foo.green, foo.blue); else return Qnil; } @@ -3703,9 +3701,8 @@ If omitted or nil, that stands for the selected frame's display. */) struct x_display_info *dpyinfo = check_x_display_info (terminal); Display *dpy = dpyinfo->display; - return Fcons (make_number (ProtocolVersion (dpy)), - Fcons (make_number (ProtocolRevision (dpy)), - Fcons (make_number (VendorRelease (dpy)), Qnil))); + return list3i (ProtocolVersion (dpy), ProtocolRevision (dpy), + VendorRelease (dpy)); } DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, diff --git a/src/xterm.c b/src/xterm.c index b5274992293..88433b6c0b3 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -8951,10 +8951,7 @@ x_ewmh_activate_frame (FRAME_PTR f) XSETFRAME (frame, f); x_send_client_event (frame, make_number (0), frame, dpyinfo->Xatom_net_active_window, - make_number (32), - Fcons (make_number (1), - Fcons (make_number (last_user_time), - Qnil))); + make_number (32), list2i (1, last_user_time)); } } -- 2.39.2