diff options
| author | Dmitry Antipov | 2012-07-15 11:57:54 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-15 11:57:54 +0400 |
| commit | 9730daca4425e2014ff43a3b1b205b598e63c72a (patch) | |
| tree | aa0ddedd9fab09a7a40cc8bff5a8cbf671fd9c62 /src | |
| parent | 2e2d2a13e59e6332ea2623cfe4b3c1cd5afaed2c (diff) | |
| download | emacs-9730daca4425e2014ff43a3b1b205b598e63c72a.tar.gz emacs-9730daca4425e2014ff43a3b1b205b598e63c72a.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/alloc.c | 7 | ||||
| -rw-r--r-- | src/font.c | 33 | ||||
| -rw-r--r-- | src/keymap.c | 4 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2012-07-15 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Use zero_vector where appropriate. | ||
| 4 | * alloc.c (zero_vector): Define as Lisp_Object. Adjust users | ||
| 5 | accordingly. | ||
| 6 | * lisp.h (zero_vector): New declaration. | ||
| 7 | * font.c (null_vector): Remove. | ||
| 8 | (syms_of_font): Remove initialization and staticpro. | ||
| 9 | (font_list_entities, font_find_for_lface): Change to use zero_vector. | ||
| 10 | * keymap.c (Faccessible_keymaps): Likewise. | ||
| 11 | |||
| 1 | 2012-07-15 Leo Liu <sdl.web@gmail.com> | 12 | 2012-07-15 Leo Liu <sdl.web@gmail.com> |
| 2 | 13 | ||
| 3 | * fringe.c: Fix typo in comments. | 14 | * 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; | |||
| 2973 | 2973 | ||
| 2974 | /* The only vector with 0 slots, allocated from pure space. */ | 2974 | /* The only vector with 0 slots, allocated from pure space. */ |
| 2975 | 2975 | ||
| 2976 | static struct Lisp_Vector *zero_vector; | 2976 | Lisp_Object zero_vector; |
| 2977 | 2977 | ||
| 2978 | /* Get a new vector block. */ | 2978 | /* Get a new vector block. */ |
| 2979 | 2979 | ||
| @@ -2997,8 +2997,7 @@ allocate_vector_block (void) | |||
| 2997 | static void | 2997 | static void |
| 2998 | init_vectors (void) | 2998 | init_vectors (void) |
| 2999 | { | 2999 | { |
| 3000 | zero_vector = pure_alloc (header_size, Lisp_Vectorlike); | 3000 | zero_vector = make_pure_vector (0); |
| 3001 | zero_vector->header.size = 0; | ||
| 3002 | } | 3001 | } |
| 3003 | 3002 | ||
| 3004 | /* Allocate vector from a vector block. */ | 3003 | /* Allocate vector from a vector block. */ |
| @@ -3190,7 +3189,7 @@ allocate_vectorlike (ptrdiff_t len) | |||
| 3190 | /* eassert (!handling_signal); */ | 3189 | /* eassert (!handling_signal); */ |
| 3191 | 3190 | ||
| 3192 | if (len == 0) | 3191 | if (len == 0) |
| 3193 | p = zero_vector; | 3192 | p = XVECTOR (zero_vector); |
| 3194 | else | 3193 | else |
| 3195 | { | 3194 | { |
| 3196 | size_t nbytes = header_size + len * word_size; | 3195 | 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; | |||
| 59 | /* Unicode category `Cf'. */ | 59 | /* Unicode category `Cf'. */ |
| 60 | static Lisp_Object QCf; | 60 | static Lisp_Object QCf; |
| 61 | 61 | ||
| 62 | /* Special vector of zero length. This is repeatedly used by (struct | ||
| 63 | font_driver *)->list when a specified font is not found. */ | ||
| 64 | static Lisp_Object null_vector; | ||
| 65 | |||
| 66 | /* Vector of Vfont_weight_table, Vfont_slant_table, and Vfont_width_table. */ | 62 | /* Vector of Vfont_weight_table, Vfont_slant_table, and Vfont_width_table. */ |
| 67 | static Lisp_Object font_style_table; | 63 | static Lisp_Object font_style_table; |
| 68 | 64 | ||
| @@ -2748,7 +2744,7 @@ font_list_entities (Lisp_Object frame, Lisp_Object spec) | |||
| 2748 | 2744 | ||
| 2749 | val = driver_list->driver->list (frame, scratch_font_spec); | 2745 | val = driver_list->driver->list (frame, scratch_font_spec); |
| 2750 | if (NILP (val)) | 2746 | if (NILP (val)) |
| 2751 | val = null_vector; | 2747 | val = zero_vector; |
| 2752 | else | 2748 | else |
| 2753 | val = Fvconcat (1, &val); | 2749 | val = Fvconcat (1, &val); |
| 2754 | copy = copy_font_spec (scratch_font_spec); | 2750 | 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) | |||
| 3104 | { | 3100 | { |
| 3105 | registry[0] = DEFAULT_ENCODING; | 3101 | registry[0] = DEFAULT_ENCODING; |
| 3106 | registry[1] = Qascii_0; | 3102 | registry[1] = Qascii_0; |
| 3107 | registry[2] = null_vector; | 3103 | registry[2] = zero_vector; |
| 3108 | } | 3104 | } |
| 3109 | else | 3105 | else |
| 3110 | registry[1] = null_vector; | 3106 | registry[1] = zero_vector; |
| 3111 | 3107 | ||
| 3112 | if (c >= 0 && ! NILP (AREF (spec, FONT_REGISTRY_INDEX))) | 3108 | if (c >= 0 && ! NILP (AREF (spec, FONT_REGISTRY_INDEX))) |
| 3113 | { | 3109 | { |
| @@ -3136,20 +3132,20 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) | |||
| 3136 | ASET (work, FONT_SIZE_INDEX, Qnil); | 3132 | ASET (work, FONT_SIZE_INDEX, Qnil); |
| 3137 | foundry[0] = AREF (work, FONT_FOUNDRY_INDEX); | 3133 | foundry[0] = AREF (work, FONT_FOUNDRY_INDEX); |
| 3138 | if (! NILP (foundry[0])) | 3134 | if (! NILP (foundry[0])) |
| 3139 | foundry[1] = null_vector; | 3135 | foundry[1] = zero_vector; |
| 3140 | else if (STRINGP (attrs[LFACE_FOUNDRY_INDEX])) | 3136 | else if (STRINGP (attrs[LFACE_FOUNDRY_INDEX])) |
| 3141 | { | 3137 | { |
| 3142 | val = attrs[LFACE_FOUNDRY_INDEX]; | 3138 | val = attrs[LFACE_FOUNDRY_INDEX]; |
| 3143 | foundry[0] = font_intern_prop (SSDATA (val), SBYTES (val), 1); | 3139 | foundry[0] = font_intern_prop (SSDATA (val), SBYTES (val), 1); |
| 3144 | foundry[1] = Qnil; | 3140 | foundry[1] = Qnil; |
| 3145 | foundry[2] = null_vector; | 3141 | foundry[2] = zero_vector; |
| 3146 | } | 3142 | } |
| 3147 | else | 3143 | else |
| 3148 | foundry[0] = Qnil, foundry[1] = null_vector; | 3144 | foundry[0] = Qnil, foundry[1] = zero_vector; |
| 3149 | 3145 | ||
| 3150 | adstyle[0] = AREF (work, FONT_ADSTYLE_INDEX); | 3146 | adstyle[0] = AREF (work, FONT_ADSTYLE_INDEX); |
| 3151 | if (! NILP (adstyle[0])) | 3147 | if (! NILP (adstyle[0])) |
| 3152 | adstyle[1] = null_vector; | 3148 | adstyle[1] = zero_vector; |
| 3153 | else if (FONTP (attrs[LFACE_FONT_INDEX])) | 3149 | else if (FONTP (attrs[LFACE_FONT_INDEX])) |
| 3154 | { | 3150 | { |
| 3155 | Lisp_Object face_font = attrs[LFACE_FONT_INDEX]; | 3151 | 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) | |||
| 3158 | { | 3154 | { |
| 3159 | adstyle[0] = AREF (face_font, FONT_ADSTYLE_INDEX); | 3155 | adstyle[0] = AREF (face_font, FONT_ADSTYLE_INDEX); |
| 3160 | adstyle[1] = Qnil; | 3156 | adstyle[1] = Qnil; |
| 3161 | adstyle[2] = null_vector; | 3157 | adstyle[2] = zero_vector; |
| 3162 | } | 3158 | } |
| 3163 | else | 3159 | else |
| 3164 | adstyle[0] = Qnil, adstyle[1] = null_vector; | 3160 | adstyle[0] = Qnil, adstyle[1] = zero_vector; |
| 3165 | } | 3161 | } |
| 3166 | else | 3162 | else |
| 3167 | adstyle[0] = Qnil, adstyle[1] = null_vector; | 3163 | adstyle[0] = Qnil, adstyle[1] = zero_vector; |
| 3168 | 3164 | ||
| 3169 | 3165 | ||
| 3170 | val = AREF (work, FONT_FAMILY_INDEX); | 3166 | 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) | |||
| 3177 | { | 3173 | { |
| 3178 | family = alloca ((sizeof family[0]) * 2); | 3174 | family = alloca ((sizeof family[0]) * 2); |
| 3179 | family[0] = Qnil; | 3175 | family[0] = Qnil; |
| 3180 | family[1] = null_vector; /* terminator. */ | 3176 | family[1] = zero_vector; /* terminator. */ |
| 3181 | } | 3177 | } |
| 3182 | else | 3178 | else |
| 3183 | { | 3179 | { |
| @@ -3192,7 +3188,7 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) | |||
| 3192 | family[i] = XCAR (alters); | 3188 | family[i] = XCAR (alters); |
| 3193 | if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | 3189 | if (NILP (AREF (spec, FONT_FAMILY_INDEX))) |
| 3194 | family[i++] = Qnil; | 3190 | family[i++] = Qnil; |
| 3195 | family[i] = null_vector; | 3191 | family[i] = zero_vector; |
| 3196 | } | 3192 | } |
| 3197 | else | 3193 | else |
| 3198 | { | 3194 | { |
| @@ -3201,7 +3197,7 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) | |||
| 3201 | family[i++] = val; | 3197 | family[i++] = val; |
| 3202 | if (NILP (AREF (spec, FONT_FAMILY_INDEX))) | 3198 | if (NILP (AREF (spec, FONT_FAMILY_INDEX))) |
| 3203 | family[i++] = Qnil; | 3199 | family[i++] = Qnil; |
| 3204 | family[i] = null_vector; | 3200 | family[i] = zero_vector; |
| 3205 | } | 3201 | } |
| 3206 | } | 3202 | } |
| 3207 | 3203 | ||
| @@ -5095,9 +5091,6 @@ syms_of_font (void) | |||
| 5095 | 5091 | ||
| 5096 | DEFSYM (QCuser_spec, "user-spec"); | 5092 | DEFSYM (QCuser_spec, "user-spec"); |
| 5097 | 5093 | ||
| 5098 | staticpro (&null_vector); | ||
| 5099 | null_vector = Fmake_vector (make_number (0), Qnil); | ||
| 5100 | |||
| 5101 | staticpro (&scratch_font_spec); | 5094 | staticpro (&scratch_font_spec); |
| 5102 | scratch_font_spec = Ffont_spec (0, NULL); | 5095 | scratch_font_spec = Ffont_spec (0, NULL); |
| 5103 | staticpro (&scratch_font_prefer); | 5096 | 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. */) | |||
| 2010 | return Qnil; | 2010 | return Qnil; |
| 2011 | } | 2011 | } |
| 2012 | else | 2012 | else |
| 2013 | maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), | 2013 | maps = Fcons (Fcons (zero_vector, get_keymap (keymap, 1, 0)), Qnil); |
| 2014 | get_keymap (keymap, 1, 0)), | ||
| 2015 | Qnil); | ||
| 2016 | 2014 | ||
| 2017 | /* For each map in the list maps, | 2015 | /* For each map in the list maps, |
| 2018 | look at any other maps it points to, | 2016 | 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); | |||
| 2605 | extern void refill_memory_reserve (void); | 2605 | extern void refill_memory_reserve (void); |
| 2606 | #endif | 2606 | #endif |
| 2607 | extern const char *pending_malloc_warning; | 2607 | extern const char *pending_malloc_warning; |
| 2608 | extern Lisp_Object zero_vector; | ||
| 2608 | extern Lisp_Object *stack_base; | 2609 | extern Lisp_Object *stack_base; |
| 2609 | extern Lisp_Object list1 (Lisp_Object); | 2610 | extern Lisp_Object list1 (Lisp_Object); |
| 2610 | extern Lisp_Object list2 (Lisp_Object, Lisp_Object); | 2611 | extern Lisp_Object list2 (Lisp_Object, Lisp_Object); |