Commit f135e94e authored by Paul Eggert's avatar Paul Eggert
Browse files

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.
parent 91953c11
2014-09-21 Paul Eggert <eggert@cs.ucla.edu>
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.
2014-09-18 Dmitry Antipov <dmantipov@yandex.ru>
 
More and more stack-allocated Lisp objects if USE_LOCAL_ALLOCATORS.
......
......@@ -1063,7 +1063,7 @@ default_pixels_per_inch_y (void)
/* Handy macro to construct an argument to Fmodify_frame_parameters. */
#define FRAME_PARAMETER(parameter, value) \
local_list1 (scoped_cons (parameter, value))
scoped_list1 (scoped_cons (parameter, value))
/* False means there are no visible garbaged frames. */
extern bool frame_garbaged;
......
......@@ -4590,13 +4590,15 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
/* Convenient utility macros similar to listX functions. */
#if USE_STACK_LISP_OBJECTS
# define scoped_list1(x) scoped_cons (x, Qnil)
# define scoped_list2(x, y) scoped_cons (x, scoped_list1 (y))
# define scoped_list3(x, y, z) scoped_cons (x, scoped_list2 (y, z))
# define scoped_list1(a) scoped_cons (a, Qnil)
# define scoped_list2(a, b) scoped_cons (a, scoped_list1 (b))
# define scoped_list3(a, b, c) scoped_cons (a, scoped_list2 (b, c))
# define scoped_list4(a, b, c, d) scoped_cons (a, scoped_list3 (b, c, d))
#else
# define scoped_list1(x) list1 (x)
# define scoped_list2(x, y) list2 (x, y)
# define scoped_list3(x, y, z) list3 (x, y, z)
# define scoped_list1(a) list1 (a)
# define scoped_list2(a, b) list2 (a, b)
# define scoped_list3(a, b, c) list3 (a, b, c)
# define scoped_list4(a, b, c, d) list4 (a, b, c, d)
#endif
/* Local allocators require both statement expressions and a
......@@ -4620,10 +4622,10 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
make_lisp_ptr (c_, Lisp_Cons); \
})
# define local_list1(x) local_cons (x, Qnil)
# define local_list2(x, y) local_cons (x, local_list1 (y))
# define local_list3(x, y, z) local_cons (x, local_list2 (y, z))
# define local_list4(x, y, z, t) local_cons (x, local_list3 (y, z, t))
# define local_list1(a) local_cons (a, Qnil)
# define local_list2(a, b) local_cons (a, local_list1 (b))
# define local_list3(a, b, c) local_cons (a, local_list2 (b, c))
# define local_list4(a, b, c, d) local_cons (a, local_list3 (b, c, d))
/* Return a function-scoped vector of length SIZE, with each element
being INIT. */
......@@ -4670,14 +4672,46 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons));
#else
/* Safer but slower implementations. */
# define local_cons(car, cdr) Fcons (car, cdr)
# define local_list1(x) list1 (x)
# define local_list2(x, y) list2 (x, y)
# define local_list3(x, y, z) list3 (x, y, z)
# define local_list4(x, y, z, t) list4 (x, y, z, t)
# define make_local_vector(size, init) Fmake_vector (make_number (size), init)
# define make_local_string(data, nbytes) make_string (data, nbytes)
# define build_local_string(data) build_string (data)
INLINE Lisp_Object
local_cons (Lisp_Object car, Lisp_Object cdr)
{
return Fcons (car, cdr);
}
INLINE Lisp_Object
local_list1 (Lisp_Object a)
{
return list1 (a);
}
INLINE Lisp_Object
local_list2 (Lisp_Object a, Lisp_Object b)
{
return list2 (a, b);
}
INLINE Lisp_Object
local_list3 (Lisp_Object a, Lisp_Object b, Lisp_Object c)
{
return list3 (a, b, c);
}
INLINE Lisp_Object
local_list4 (Lisp_Object a, Lisp_Object b, Lisp_Object c, Lisp_Object d)
{
return list4 (a, b, c, d);
}
INLINE Lisp_Object
make_local_vector (ptrdiff_t size, Lisp_Object init)
{
return Fmake_vector (make_number (size), init);
}
INLINE Lisp_Object
make_local_string (char const *str, ptrdiff_t nbytes)
{
return make_string (str, nbytes);
}
INLINE Lisp_Object
build_local_string (const char *str)
{
return build_string (str);
}
#endif
......
......@@ -12038,11 +12038,11 @@ static void
build_desired_tool_bar_string (struct frame *f)
{
int i, size, size_needed;
struct gcpro gcpro1, gcpro2, gcpro3;
Lisp_Object image, plist, props;
struct gcpro gcpro1, gcpro2;
Lisp_Object image, plist;
 
image = plist = props = Qnil;
GCPRO3 (image, plist, props);
image = plist = Qnil;
GCPRO2 (image, plist);
 
/* Prepare F->desired_tool_bar_string. If we can reuse it, do so.
Otherwise, make a new string. */
......@@ -12061,9 +12061,12 @@ build_desired_tool_bar_string (struct frame *f)
(f, Fmake_string (make_number (size_needed), make_number (' ')));
else
{
props = local_list4 (Qdisplay, Qnil, Qmenu_item, Qnil);
Lisp_Object props = scoped_list4 (Qdisplay, Qnil, Qmenu_item, Qnil);
struct gcpro gcpro1;
GCPRO1 (props);
Fremove_text_properties (make_number (0), make_number (size),
props, f->desired_tool_bar_string);
UNGCPRO;
}
 
/* Put a `display' property on the string for the images to display,
......@@ -12174,8 +12177,11 @@ build_desired_tool_bar_string (struct frame *f)
the start of this item's properties in the tool-bar items
vector. */
image = Fcons (Qimage, plist);
props = local_list4 (Qdisplay, image, Qmenu_item,
make_number (i * TOOL_BAR_ITEM_NSLOTS));
Lisp_Object props
= scoped_list4 (Qdisplay, image, Qmenu_item,
make_number (i * TOOL_BAR_ITEM_NSLOTS));
struct gcpro gcpro1;
GCPRO1 (props);
 
/* Let the last image hide all remaining spaces in the tool bar
string. The string can be longer than needed when we reuse a
......@@ -12186,6 +12192,7 @@ build_desired_tool_bar_string (struct frame *f)
end = i + 1;
Fadd_text_properties (make_number (i), make_number (end),
props, f->desired_tool_bar_string);
UNGCPRO;
#undef PROP
}
 
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment