aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2014-09-21 15:49:24 -0700
committerPaul Eggert2014-09-21 15:49:24 -0700
commitf135e94e4ecb4c6d3f88c7e028c935c2858f2e02 (patch)
treecce4bcd9dcf5a580b6e42407166013be6ce351fa /src/lisp.h
parent91953c118721024b3b8db0d4fb318898203a1e56 (diff)
downloademacs-f135e94e4ecb4c6d3f88c7e028c935c2858f2e02.tar.gz
emacs-f135e94e4ecb4c6d3f88c7e028c935c2858f2e02.zip
Minor improvements to new stack-allocated Lisp objects.
* frame.h (FRAME_PARAMETER): Prefer scoped_list1 to local_list1 where either would do. * lisp.h (scoped_list4): New macro. (local_cons, local_list1, local_list2, local_list3, local_list4) (make_local_vector, make_local_string, build_local_string): Prefer functions to macros where either would do. * xdisp.c (build_desired_tool_bar_string): Prefer scoped_list4 to local_list4 where either would do.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h70
1 files changed, 52 insertions, 18 deletions
diff --git a/src/lisp.h b/src/lisp.h
index b8e75f90ef5..1347b35f046 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4590,13 +4590,15 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
4590/* Convenient utility macros similar to listX functions. */ 4590/* Convenient utility macros similar to listX functions. */
4591 4591
4592#if USE_STACK_LISP_OBJECTS 4592#if USE_STACK_LISP_OBJECTS
4593# define scoped_list1(x) scoped_cons (x, Qnil) 4593# define scoped_list1(a) scoped_cons (a, Qnil)
4594# define scoped_list2(x, y) scoped_cons (x, scoped_list1 (y)) 4594# define scoped_list2(a, b) scoped_cons (a, scoped_list1 (b))
4595# define scoped_list3(x, y, z) scoped_cons (x, scoped_list2 (y, z)) 4595# define scoped_list3(a, b, c) scoped_cons (a, scoped_list2 (b, c))
4596# define scoped_list4(a, b, c, d) scoped_cons (a, scoped_list3 (b, c, d))
4596#else 4597#else
4597# define scoped_list1(x) list1 (x) 4598# define scoped_list1(a) list1 (a)
4598# define scoped_list2(x, y) list2 (x, y) 4599# define scoped_list2(a, b) list2 (a, b)
4599# define scoped_list3(x, y, z) list3 (x, y, z) 4600# define scoped_list3(a, b, c) list3 (a, b, c)
4601# define scoped_list4(a, b, c, d) list4 (a, b, c, d)
4600#endif 4602#endif
4601 4603
4602/* Local allocators require both statement expressions and a 4604/* Local allocators require both statement expressions and a
@@ -4620,10 +4622,10 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
4620 make_lisp_ptr (c_, Lisp_Cons); \ 4622 make_lisp_ptr (c_, Lisp_Cons); \
4621 }) 4623 })
4622 4624
4623# define local_list1(x) local_cons (x, Qnil) 4625# define local_list1(a) local_cons (a, Qnil)
4624# define local_list2(x, y) local_cons (x, local_list1 (y)) 4626# define local_list2(a, b) local_cons (a, local_list1 (b))
4625# define local_list3(x, y, z) local_cons (x, local_list2 (y, z)) 4627# define local_list3(a, b, c) local_cons (a, local_list2 (b, c))
4626# define local_list4(x, y, z, t) local_cons (x, local_list3 (y, z, t)) 4628# define local_list4(a, b, c, d) local_cons (a, local_list3 (b, c, d))
4627 4629
4628/* Return a function-scoped vector of length SIZE, with each element 4630/* Return a function-scoped vector of length SIZE, with each element
4629 being INIT. */ 4631 being INIT. */
@@ -4670,14 +4672,46 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
4670#else 4672#else
4671 4673
4672/* Safer but slower implementations. */ 4674/* Safer but slower implementations. */
4673# define local_cons(car, cdr) Fcons (car, cdr) 4675INLINE Lisp_Object
4674# define local_list1(x) list1 (x) 4676local_cons (Lisp_Object car, Lisp_Object cdr)
4675# define local_list2(x, y) list2 (x, y) 4677{
4676# define local_list3(x, y, z) list3 (x, y, z) 4678 return Fcons (car, cdr);
4677# define local_list4(x, y, z, t) list4 (x, y, z, t) 4679}
4678# define make_local_vector(size, init) Fmake_vector (make_number (size), init) 4680INLINE Lisp_Object
4679# define make_local_string(data, nbytes) make_string (data, nbytes) 4681local_list1 (Lisp_Object a)
4680# define build_local_string(data) build_string (data) 4682{
4683 return list1 (a);
4684}
4685INLINE Lisp_Object
4686local_list2 (Lisp_Object a, Lisp_Object b)
4687{
4688 return list2 (a, b);
4689}
4690INLINE Lisp_Object
4691local_list3 (Lisp_Object a, Lisp_Object b, Lisp_Object c)
4692{
4693 return list3 (a, b, c);
4694}
4695INLINE Lisp_Object
4696local_list4 (Lisp_Object a, Lisp_Object b, Lisp_Object c, Lisp_Object d)
4697{
4698 return list4 (a, b, c, d);
4699}
4700INLINE Lisp_Object
4701make_local_vector (ptrdiff_t size, Lisp_Object init)
4702{
4703 return Fmake_vector (make_number (size), init);
4704}
4705INLINE Lisp_Object
4706make_local_string (char const *str, ptrdiff_t nbytes)
4707{
4708 return make_string (str, nbytes);
4709}
4710INLINE Lisp_Object
4711build_local_string (const char *str)
4712{
4713 return build_string (str);
4714}
4681#endif 4715#endif
4682 4716
4683 4717