From 9730daca4425e2014ff43a3b1b205b598e63c72a Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Sun, 15 Jul 2012 11:57:54 +0400 Subject: [PATCH] Use zero_vector where appropriate. * alloc.c (zero_vector): Define as Lisp_Object. Adjust users accordingly. * lisp.h (zero_vector): New declaration. * font.c (null_vector): Remove. (syms_of_font): Remove initialization and staticpro. (font_list_entities, font_find_for_lface): Change to use zero_vector. * keymap.c (Faccessible_keymaps): Likewise. --- src/ChangeLog | 11 +++++++++++ src/alloc.c | 7 +++---- src/font.c | 33 +++++++++++++-------------------- src/keymap.c | 4 +--- src/lisp.h | 1 + 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 67bbf0b5bb7..2a6f2ebb42b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2012-07-15 Dmitry Antipov + + Use zero_vector where appropriate. + * alloc.c (zero_vector): Define as Lisp_Object. Adjust users + accordingly. + * lisp.h (zero_vector): New declaration. + * font.c (null_vector): Remove. + (syms_of_font): Remove initialization and staticpro. + (font_list_entities, font_find_for_lface): Change to use zero_vector. + * keymap.c (Faccessible_keymaps): Likewise. + 2012-07-15 Leo Liu * fringe.c: Fix typo in comments. diff --git a/src/alloc.c b/src/alloc.c index ac200254b8c..1df775a093b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2973,7 +2973,7 @@ static struct Lisp_Vector *large_vectors; /* The only vector with 0 slots, allocated from pure space. */ -static struct Lisp_Vector *zero_vector; +Lisp_Object zero_vector; /* Get a new vector block. */ @@ -2997,8 +2997,7 @@ allocate_vector_block (void) static void init_vectors (void) { - zero_vector = pure_alloc (header_size, Lisp_Vectorlike); - zero_vector->header.size = 0; + zero_vector = make_pure_vector (0); } /* Allocate vector from a vector block. */ @@ -3190,7 +3189,7 @@ allocate_vectorlike (ptrdiff_t len) /* eassert (!handling_signal); */ if (len == 0) - p = zero_vector; + p = XVECTOR (zero_vector); else { size_t nbytes = header_size + len * word_size; diff --git a/src/font.c b/src/font.c index 74f58878391..5b01a1f44d6 100644 --- a/src/font.c +++ b/src/font.c @@ -59,10 +59,6 @@ Lisp_Object Qascii_0, Qiso8859_1, Qiso10646_1, Qunicode_bmp, Qunicode_sip; /* Unicode category `Cf'. */ static Lisp_Object QCf; -/* Special vector of zero length. This is repeatedly used by (struct - font_driver *)->list when a specified font is not found. */ -static Lisp_Object null_vector; - /* Vector of Vfont_weight_table, Vfont_slant_table, and Vfont_width_table. */ static Lisp_Object font_style_table; @@ -2748,7 +2744,7 @@ font_list_entities (Lisp_Object frame, Lisp_Object spec) val = driver_list->driver->list (frame, scratch_font_spec); if (NILP (val)) - val = null_vector; + val = zero_vector; else val = Fvconcat (1, &val); copy = copy_font_spec (scratch_font_spec); @@ -3104,10 +3100,10 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) { registry[0] = DEFAULT_ENCODING; registry[1] = Qascii_0; - registry[2] = null_vector; + registry[2] = zero_vector; } else - registry[1] = null_vector; + registry[1] = zero_vector; if (c >= 0 && ! NILP (AREF (spec, FONT_REGISTRY_INDEX))) { @@ -3136,20 +3132,20 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) ASET (work, FONT_SIZE_INDEX, Qnil); foundry[0] = AREF (work, FONT_FOUNDRY_INDEX); if (! NILP (foundry[0])) - foundry[1] = null_vector; + foundry[1] = zero_vector; else if (STRINGP (attrs[LFACE_FOUNDRY_INDEX])) { val = attrs[LFACE_FOUNDRY_INDEX]; foundry[0] = font_intern_prop (SSDATA (val), SBYTES (val), 1); foundry[1] = Qnil; - foundry[2] = null_vector; + foundry[2] = zero_vector; } else - foundry[0] = Qnil, foundry[1] = null_vector; + foundry[0] = Qnil, foundry[1] = zero_vector; adstyle[0] = AREF (work, FONT_ADSTYLE_INDEX); if (! NILP (adstyle[0])) - adstyle[1] = null_vector; + adstyle[1] = zero_vector; else if (FONTP (attrs[LFACE_FONT_INDEX])) { Lisp_Object face_font = attrs[LFACE_FONT_INDEX]; @@ -3158,13 +3154,13 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) { adstyle[0] = AREF (face_font, FONT_ADSTYLE_INDEX); adstyle[1] = Qnil; - adstyle[2] = null_vector; + adstyle[2] = zero_vector; } else - adstyle[0] = Qnil, adstyle[1] = null_vector; + adstyle[0] = Qnil, adstyle[1] = zero_vector; } else - adstyle[0] = Qnil, adstyle[1] = null_vector; + adstyle[0] = Qnil, adstyle[1] = zero_vector; val = AREF (work, FONT_FAMILY_INDEX); @@ -3177,7 +3173,7 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) { family = alloca ((sizeof family[0]) * 2); family[0] = Qnil; - family[1] = null_vector; /* terminator. */ + family[1] = zero_vector; /* terminator. */ } else { @@ -3192,7 +3188,7 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) family[i] = XCAR (alters); if (NILP (AREF (spec, FONT_FAMILY_INDEX))) family[i++] = Qnil; - family[i] = null_vector; + family[i] = zero_vector; } else { @@ -3201,7 +3197,7 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) family[i++] = val; if (NILP (AREF (spec, FONT_FAMILY_INDEX))) family[i++] = Qnil; - family[i] = null_vector; + family[i] = zero_vector; } } @@ -5095,9 +5091,6 @@ syms_of_font (void) DEFSYM (QCuser_spec, "user-spec"); - staticpro (&null_vector); - null_vector = Fmake_vector (make_number (0), Qnil); - staticpro (&scratch_font_spec); scratch_font_spec = Ffont_spec (0, NULL); staticpro (&scratch_font_prefer); diff --git a/src/keymap.c b/src/keymap.c index cfc1e2e495c..510c5ea7f3e 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -2010,9 +2010,7 @@ then the value includes only maps for prefixes that start with PREFIX. */) return Qnil; } else - maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), - get_keymap (keymap, 1, 0)), - Qnil); + maps = Fcons (Fcons (zero_vector, get_keymap (keymap, 1, 0)), Qnil); /* For each map in the list maps, look at any other maps it points to, diff --git a/src/lisp.h b/src/lisp.h index 529feb99fd5..0bfe3c78118 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2605,6 +2605,7 @@ extern void mark_object (Lisp_Object); extern void refill_memory_reserve (void); #endif extern const char *pending_malloc_warning; +extern Lisp_Object zero_vector; extern Lisp_Object *stack_base; extern Lisp_Object list1 (Lisp_Object); extern Lisp_Object list2 (Lisp_Object, Lisp_Object); -- 2.39.2