[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109223: Utility function to make a l
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109223: Utility function to make a list from specified amount of objects. |
Date: |
Fri, 27 Jul 2012 10:04:35 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109223
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2012-07-27 10:04:35 +0400
message:
Utility function to make a list from specified amount of objects.
* lisp.h (enum constype): New datatype.
(listn): New prototype.
* alloc.c (listn): New function.
(Fmemory_use_count, syms_of_alloc): Use it.
* buffer.c (syms_of_buffer): Likewise.
* callint.c (syms_of_callint): Likewise.
* charset.c (define_charset_internal): Likewise.
* coding.c (syms_of_coding): Likewise.
* keymap.c (syms_of_keymap): Likewise.
* search.c (syms_of_search): Likewise.
* syntax.c (syms_of_syntax): Likewise.
* w32.c (init_environment): Likewise.
* w32fns.c (Fw32_battery_status, syms_of_w32fns): Likewise.
* xdisp.c (syms_of_xdisp): Likewise.
* xfns.c (syms_of_xfns): Likewise.
modified:
src/ChangeLog
src/alloc.c
src/buffer.c
src/callint.c
src/charset.c
src/coding.c
src/keymap.c
src/lisp.h
src/search.c
src/syntax.c
src/w32.c
src/w32fns.c
src/xdisp.c
src/xfns.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-07-27 02:47:07 +0000
+++ b/src/ChangeLog 2012-07-27 06:04:35 +0000
@@ -1,5 +1,24 @@
2012-07-27 Dmitry Antipov <address@hidden>
+ Utility function to make a list from specified amount of objects.
+ * lisp.h (enum constype): New datatype.
+ (listn): New prototype.
+ * alloc.c (listn): New function.
+ (Fmemory_use_count, syms_of_alloc): Use it.
+ * buffer.c (syms_of_buffer): Likewise.
+ * callint.c (syms_of_callint): Likewise.
+ * charset.c (define_charset_internal): Likewise.
+ * coding.c (syms_of_coding): Likewise.
+ * keymap.c (syms_of_keymap): Likewise.
+ * search.c (syms_of_search): Likewise.
+ * syntax.c (syms_of_syntax): Likewise.
+ * w32.c (init_environment): Likewise.
+ * w32fns.c (Fw32_battery_status, syms_of_w32fns): Likewise.
+ * xdisp.c (syms_of_xdisp): Likewise.
+ * xfns.c (syms_of_xfns): Likewise.
+
+2012-07-27 Dmitry Antipov <address@hidden>
+
Fast save_excursion_save and save_excursion_restore.
* lisp.h (struct Lisp_Excursion): New data type.
(PVEC_EXCURSION): New pseudovector type.
=== modified file 'src/alloc.c'
--- a/src/alloc.c 2012-07-27 02:47:07 +0000
+++ b/src/alloc.c 2012-07-27 06:04:35 +0000
@@ -2811,6 +2811,38 @@
Fcons (arg5, Qnil)))));
}
+/* Make a list of COUNT Lisp_Objects, where ARG is the
+ first one. Allocate conses from pure space if TYPE
+ is PURE, or allocate as usual if type is HEAP. */
+
+Lisp_Object
+listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...)
+{
+ va_list ap;
+ ptrdiff_t i;
+ Lisp_Object val, *objp;
+
+ /* Change to SAFE_ALLOCA if you hit this eassert. */
+ eassert (count <= MAX_ALLOCA / sizeof (Lisp_Object));
+
+ objp = alloca (count * sizeof (Lisp_Object));
+ objp[0] = arg;
+ va_start (ap, arg);
+ for (i = 1; i < count; i++)
+ objp[i] = va_arg (ap, Lisp_Object);
+ va_end (ap);
+
+ for (i = 0, val = Qnil; i < count; i++)
+ {
+ if (type == PURE)
+ val = pure_cons (objp[i], val);
+ else if (type == HEAP)
+ val = Fcons (objp[i], val);
+ else
+ abort ();
+ }
+ return val;
+}
DEFUN ("list", Flist, Slist, 0, MANY, 0,
doc: /* Return a newly created list with specified arguments as
elements.
@@ -6649,18 +6681,15 @@
(but the contents of a buffer's text do not count here). */)
(void)
{
- Lisp_Object consed[8];
-
- consed[0] = bounded_number (cons_cells_consed);
- consed[1] = bounded_number (floats_consed);
- consed[2] = bounded_number (vector_cells_consed);
- consed[3] = bounded_number (symbols_consed);
- consed[4] = bounded_number (string_chars_consed);
- consed[5] = bounded_number (misc_objects_consed);
- consed[6] = bounded_number (intervals_consed);
- consed[7] = bounded_number (strings_consed);
-
- return Flist (8, consed);
+ return listn (HEAP, 8,
+ bounded_number (cons_cells_consed),
+ bounded_number (floats_consed),
+ bounded_number (vector_cells_consed),
+ bounded_number (symbols_consed),
+ bounded_number (string_chars_consed),
+ bounded_number (misc_objects_consed),
+ bounded_number (intervals_consed),
+ bounded_number (strings_consed));
}
/* Find at most FIND_MAX symbols which have OBJ as their value or
@@ -6841,8 +6870,8 @@
/* We build this in advance because if we wait until we need it, we might
not be able to allocate the memory to hold it. */
Vmemory_signal_data
- = pure_cons (Qerror,
- pure_cons (build_pure_c_string ("Memory exhausted--use M-x
save-some-buffers then exit and restart Emacs"), Qnil));
+ = listn (PURE, 2, Qerror,
+ build_pure_c_string ("Memory exhausted--use M-x save-some-buffers
then exit and restart Emacs"));
DEFVAR_LISP ("memory-full", Vmemory_full,
doc: /* Non-nil means Emacs cannot get much more Lisp memory.
*/);
=== modified file 'src/buffer.c'
--- a/src/buffer.c 2012-07-25 05:09:02 +0000
+++ b/src/buffer.c 2012-07-27 06:04:35 +0000
@@ -5212,7 +5212,7 @@
DEFSYM (Qkill_buffer_query_functions, "kill-buffer-query-functions");
Fput (Qprotected_field, Qerror_conditions,
- pure_cons (Qprotected_field, pure_cons (Qerror, Qnil)));
+ listn (PURE, 2, Qprotected_field, Qerror));
Fput (Qprotected_field, Qerror_message,
build_pure_c_string ("Attempt to modify a protected field"));
=== modified file 'src/callint.c'
--- a/src/callint.c 2012-07-10 16:53:26 +0000
+++ b/src/callint.c 2012-07-27 06:04:35 +0000
@@ -888,10 +888,11 @@
callint_message = Qnil;
staticpro (&callint_message);
- preserved_fns = pure_cons (intern_c_string ("region-beginning"),
- pure_cons (intern_c_string ("region-end"),
- pure_cons (intern_c_string ("point"),
- pure_cons (intern_c_string ("mark"),
Qnil))));
+ preserved_fns = listn (PURE, 4,
+ intern_c_string ("region-beginning"),
+ intern_c_string ("region-end"),
+ intern_c_string ("point"),
+ intern_c_string ("mark"));
DEFSYM (Qlist, "list");
DEFSYM (Qlet, "let");
=== modified file 'src/charset.c'
--- a/src/charset.c 2012-07-05 18:35:48 +0000
+++ b/src/charset.c 2012-07-27 06:04:35 +0000
@@ -1257,7 +1257,6 @@
{
const unsigned char *code_space = (const unsigned char *) code_space_chars;
Lisp_Object args[charset_arg_max];
- Lisp_Object plist[14];
Lisp_Object val;
int i;
@@ -1283,22 +1282,22 @@
args[charset_arg_superset] = Qnil;
args[charset_arg_unify_map] = Qnil;
- plist[0] = intern_c_string (":name");
- plist[1] = args[charset_arg_name];
- plist[2] = intern_c_string (":dimension");
- plist[3] = args[charset_arg_dimension];
- plist[4] = intern_c_string (":code-space");
- plist[5] = args[charset_arg_code_space];
- plist[6] = intern_c_string (":iso-final-char");
- plist[7] = args[charset_arg_iso_final];
- plist[8] = intern_c_string (":emacs-mule-id");
- plist[9] = args[charset_arg_emacs_mule_id];
- plist[10] = intern_c_string (":ascii-compatible-p");
- plist[11] = args[charset_arg_ascii_compatible_p];
- plist[12] = intern_c_string (":code-offset");
- plist[13] = args[charset_arg_code_offset];
-
- args[charset_arg_plist] = Flist (14, plist);
+ args[charset_arg_plist] =
+ listn (HEAP, 14,
+ intern_c_string (":name"),
+ args[charset_arg_name],
+ intern_c_string (":dimension"),
+ args[charset_arg_dimension],
+ intern_c_string (":code-space"),
+ args[charset_arg_code_space],
+ intern_c_string (":iso-final-char"),
+ args[charset_arg_iso_final],
+ intern_c_string (":emacs-mule-id"),
+ args[charset_arg_emacs_mule_id],
+ intern_c_string (":ascii-compatible-p"),
+ args[charset_arg_ascii_compatible_p],
+ intern_c_string (":code-offset"),
+ args[charset_arg_code_offset]);
Fdefine_charset_internal (charset_arg_max, args);
return XINT (CHARSET_SYMBOL_ID (name));
=== modified file 'src/coding.c'
--- a/src/coding.c 2012-07-19 03:55:59 +0000
+++ b/src/coding.c 2012-07-27 06:04:35 +0000
@@ -10411,7 +10411,7 @@
DEFSYM (Qcoding_system_error, "coding-system-error");
Fput (Qcoding_system_error, Qerror_conditions,
- pure_cons (Qcoding_system_error, pure_cons (Qerror, Qnil)));
+ listn (PURE, 2, Qcoding_system_error, Qerror));
Fput (Qcoding_system_error, Qerror_message,
build_pure_c_string ("Invalid coding system"));
=== modified file 'src/keymap.c'
--- a/src/keymap.c 2012-07-26 01:27:33 +0000
+++ b/src/keymap.c 2012-07-27 06:04:35 +0000
@@ -3702,13 +3702,12 @@
Fset (intern_c_string ("ctl-x-map"), control_x_map);
Ffset (intern_c_string ("Control-X-prefix"), control_x_map);
- exclude_keys
- = pure_cons (pure_cons (build_pure_c_string ("DEL"), build_pure_c_string
("\\d")),
- pure_cons (pure_cons (build_pure_c_string ("TAB"),
build_pure_c_string ("\\t")),
- pure_cons (pure_cons (build_pure_c_string ("RET"),
build_pure_c_string ("\\r")),
- pure_cons (pure_cons (build_pure_c_string ("ESC"),
build_pure_c_string ("\\e")),
- pure_cons (pure_cons (build_pure_c_string
("SPC"), build_pure_c_string (" ")),
- Qnil)))));
+ exclude_keys = listn (PURE, 5,
+ pure_cons (build_pure_c_string ("DEL"),
build_pure_c_string ("\\d")),
+ pure_cons (build_pure_c_string ("TAB"),
build_pure_c_string ("\\t")),
+ pure_cons (build_pure_c_string ("RET"),
build_pure_c_string ("\\r")),
+ pure_cons (build_pure_c_string ("ESC"),
build_pure_c_string ("\\e")),
+ pure_cons (build_pure_c_string ("SPC"),
build_pure_c_string (" ")));
staticpro (&exclude_keys);
DEFVAR_LISP ("define-key-rebound-commands", Vdefine_key_rebound_commands,
@@ -3761,16 +3760,16 @@
where_is_preferred_modifier = 0;
staticpro (&Vmouse_events);
- Vmouse_events = pure_cons (intern_c_string ("menu-bar"),
- pure_cons (intern_c_string ("tool-bar"),
- pure_cons (intern_c_string ("header-line"),
- pure_cons (intern_c_string ("mode-line"),
- pure_cons (intern_c_string ("mouse-1"),
- pure_cons (intern_c_string ("mouse-2"),
- pure_cons (intern_c_string ("mouse-3"),
- pure_cons (intern_c_string ("mouse-4"),
- pure_cons (intern_c_string ("mouse-5"),
- Qnil)))))))));
+ Vmouse_events = listn (PURE, 9,
+ intern_c_string ("menu-bar"),
+ intern_c_string ("tool-bar"),
+ intern_c_string ("header-line"),
+ intern_c_string ("mode-line"),
+ intern_c_string ("mouse-1"),
+ intern_c_string ("mouse-2"),
+ intern_c_string ("mouse-3"),
+ intern_c_string ("mouse-4"),
+ intern_c_string ("mouse-5"));
DEFSYM (Qsingle_key_description, "single-key-description");
DEFSYM (Qkey_description, "key-description");
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2012-07-27 02:47:07 +0000
+++ b/src/lisp.h 2012-07-27 06:04:35 +0000
@@ -2685,6 +2685,8 @@
extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object);
+enum constype {HEAP, PURE};
+extern Lisp_Object listn (enum constype, ptrdiff_t, Lisp_Object, ...);
extern _Noreturn void string_overflow (void);
extern Lisp_Object make_string (const char *, ptrdiff_t);
extern Lisp_Object make_formatted_string (char *, const char *, ...)
=== modified file 'src/search.c'
--- a/src/search.c 2012-07-11 06:14:19 +0000
+++ b/src/search.c 2012-07-27 06:04:35 +0000
@@ -3054,12 +3054,12 @@
DEFSYM (Qinvalid_regexp, "invalid-regexp");
Fput (Qsearch_failed, Qerror_conditions,
- pure_cons (Qsearch_failed, pure_cons (Qerror, Qnil)));
+ listn (PURE, 2, Qsearch_failed, Qerror));
Fput (Qsearch_failed, Qerror_message,
build_pure_c_string ("Search failed"));
Fput (Qinvalid_regexp, Qerror_conditions,
- pure_cons (Qinvalid_regexp, pure_cons (Qerror, Qnil)));
+ listn (PURE, 2, Qinvalid_regexp, Qerror));
Fput (Qinvalid_regexp, Qerror_message,
build_pure_c_string ("Invalid regexp"));
=== modified file 'src/syntax.c'
--- a/src/syntax.c 2012-07-10 08:43:46 +0000
+++ b/src/syntax.c 2012-07-27 06:04:35 +0000
@@ -3473,7 +3473,7 @@
DEFSYM (Qscan_error, "scan-error");
Fput (Qscan_error, Qerror_conditions,
- pure_cons (Qscan_error, pure_cons (Qerror, Qnil)));
+ listn (PURE, 2, Qscan_error, Qerror));
Fput (Qscan_error, Qerror_message,
build_pure_c_string ("Scan error"));
=== modified file 'src/w32.c'
--- a/src/w32.c 2012-07-10 23:24:36 +0000
+++ b/src/w32.c 2012-07-27 06:04:35 +0000
@@ -1722,13 +1722,11 @@
dwType = REG_EXPAND_SZ;
dont_free = 1;
if (!strcmp (env_vars[i].name, "HOME") && !appdata)
- {
- Lisp_Object warning[2];
- warning[0] = intern ("initialization");
- warning[1] = build_string ("Setting HOME to C:\\ by default
is deprecated");
- Vdelayed_warnings_list = Fcons (Flist (2, warning),
- Vdelayed_warnings_list);
- }
+ Vdelayed_warnings_list
+ = Fcons (listn (HEAP, 2,
+ intern ("initialization");
+ build_string ("Setting HOME to C:\\ by
default is deprecated")),
+ Vdelayed_warnings_list);
}
if (lpval)
=== modified file 'src/w32fns.c'
--- a/src/w32fns.c 2012-07-20 07:29:04 +0000
+++ b/src/w32fns.c 2012-07-27 06:04:35 +0000
@@ -6470,7 +6470,6 @@
{
Lisp_Object line_status, battery_status, battery_status_symbol;
Lisp_Object load_percentage, seconds, minutes, hours, remain;
- Lisp_Object sequences[8];
long seconds_left = (long) system_status.BatteryLifeTime;
@@ -6544,16 +6543,16 @@
_snprintf (buffer, 16, "%ld:%02ld", m / 60, m % 60);
remain = build_string (buffer);
}
- sequences[0] = Fcons (make_number ('L'), line_status);
- sequences[1] = Fcons (make_number ('B'), battery_status);
- sequences[2] = Fcons (make_number ('b'), battery_status_symbol);
- sequences[3] = Fcons (make_number ('p'), load_percentage);
- sequences[4] = Fcons (make_number ('s'), seconds);
- sequences[5] = Fcons (make_number ('m'), minutes);
- sequences[6] = Fcons (make_number ('h'), hours);
- sequences[7] = Fcons (make_number ('t'), remain);
- status = Flist (8, sequences);
+ status = listn (HEAP, 8,
+ Fcons (make_number ('L'), line_status),
+ Fcons (make_number ('B'), battery_status),
+ Fcons (make_number ('b'), battery_status_symbol),
+ Fcons (make_number ('p'), load_percentage),
+ Fcons (make_number ('s'), seconds),
+ Fcons (make_number ('m'), minutes),
+ Fcons (make_number ('h'), hours),
+ Fcons (make_number ('t'), remain));
}
return status;
}
@@ -6795,7 +6794,7 @@
Fput (Qundefined_color, Qerror_conditions,
- pure_cons (Qundefined_color, pure_cons (Qerror, Qnil)));
+ listn (PURE, 2, Qundefined_color, Qerror);
Fput (Qundefined_color, Qerror_message,
build_pure_c_string ("Undefined color"));
=== modified file 'src/xdisp.c'
--- a/src/xdisp.c 2012-07-24 16:34:15 +0000
+++ b/src/xdisp.c 2012-07-27 06:04:35 +0000
@@ -28932,14 +28932,14 @@
\(see `modify-frame-parameters'). */);
Vicon_title_format
= Vframe_title_format
- = pure_cons (intern_c_string ("multiple-frames"),
- pure_cons (build_pure_c_string ("%b"),
- pure_cons (pure_cons (empty_unibyte_string,
- pure_cons (intern_c_string
("invocation-name"),
- pure_cons
(build_pure_c_string ("@"),
-
pure_cons (intern_c_string ("system-name"),
-
Qnil)))),
- Qnil)));
+ = listn (PURE, 3,
+ intern_c_string ("multiple-frames"),
+ build_pure_c_string ("%b"),
+ listn (PURE, 4,
+ empty_unibyte_string,
+ intern_c_string ("invocation-name"),
+ build_pure_c_string ("@"),
+ intern_c_string ("system-name")));
DEFVAR_LISP ("message-log-max", Vmessage_log_max,
doc: /* Maximum number of lines to keep in the message log buffer.
=== modified file 'src/xfns.c'
--- a/src/xfns.c 2012-07-20 07:29:04 +0000
+++ b/src/xfns.c 2012-07-27 06:04:35 +0000
@@ -5822,7 +5822,7 @@
/* This is the end of symbol initialization. */
Fput (Qundefined_color, Qerror_conditions,
- pure_cons (Qundefined_color, pure_cons (Qerror, Qnil)));
+ listn (PURE, 2, Qundefined_color, Qerror));
Fput (Qundefined_color, Qerror_message,
build_pure_c_string ("Undefined color"));
- [Emacs-diffs] /srv/bzr/emacs/trunk r109223: Utility function to make a list from specified amount of objects.,
Dmitry Antipov <=