emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 91b2b3654f2: Turn macros into enums in keyboard.h


From: Stefan Kangas
Subject: Re: master 91b2b3654f2: Turn macros into enums in keyboard.h
Date: Sat, 18 Jan 2025 17:50:20 -0600

Pip Cet <pipcet@protonmail.com> writes:

> "Stefan Kangas" <stefankangas@gmail.com> writes:
>
>> branch: master
>> commit 91b2b3654f2dcf79c15a11cfe1130df6638b4a4e
>> Author: Stefan Kangas <stefankangas@gmail.com>
>> Commit: Stefan Kangas <stefankangas@gmail.com>
>>
>>     Turn macros into enums in keyboard.h
>>
>>     * src/keyboard.h (item_property_idx, menu_item_pane_idx): Turn macros
>>     into enums.
>>     (ITEM_PROPERTY_MAX): New constant.
>>     * src/keyboard.c (parse_menu_item): Use above new constant.
>> ---
>>  src/keyboard.c |  4 ++--
>>  src/keyboard.h | 60 
>> +++++++++++++++++++++++++++++++++-------------------------
>>  2 files changed, 36 insertions(+), 28 deletions(-)
>>
>> diff --git a/src/keyboard.c b/src/keyboard.c
>> index f36243dd442..c17210db8b8 100644
>> --- a/src/keyboard.c
>> +++ b/src/keyboard.c
>> @@ -8713,10 +8713,10 @@ parse_menu_item (Lisp_Object item, int inmenubar)
>>
>>    /* Create item_properties vector if necessary.  */
>>    if (NILP (item_properties))
>> -    item_properties = make_nil_vector (ITEM_PROPERTY_ENABLE + 1);
>> +    item_properties = make_nil_vector (ITEM_PROPERTY_MAX + 1);
>>
>>    /* Initialize optional entries.  */
>> -  for (i = ITEM_PROPERTY_DEF; i < ITEM_PROPERTY_ENABLE; i++)
>> +  for (i = ITEM_PROPERTY_DEF; i < ITEM_PROPERTY_MAX; i++)
>>      ASET (item_properties, i, Qnil);
>>    ASET (item_properties, ITEM_PROPERTY_ENABLE, Qt);
>
> Can we change this loop to include the last case, even though we know
> it's probably overwritten by the next line?  That would ensure it
> continues working as intended if someone makes ITEM_PROPERTY_ENABLE !=
> ITEM_PROPERTY_MAX.
>
> In optimized builds, it's likely that the dead store is eliminated.
> I've confirmed this for the (recent) GCC I'm using.

Yes, good idea.  Now done in commit 2c7b08c60a2.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]