From 67c0a1db85856740b107c948bc2b02eba2076ea6 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Fri, 23 Sep 2022 12:09:26 -0500 Subject: [PATCH] Reduce size of `complete_entry_opt_t` It's gone from 136 bytes to a 128 bytes by rearranging the items in order of decreasing alignment requirements. While this reduces the memory consumption slightly (by around 6%) for each completion we have in-memory, that translates to only around ~8KiB of savings for a command with 1000 possible completions, which is nice but ultimately not that big of a deal. The bigger benefit is that a single `complete_entry_t` might now fit in a cache line, hopefully making the process of testing completions for matches more cache friendly (and maybe even faster). --- src/complete.cpp | 4 ++-- src/complete.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/complete.cpp b/src/complete.cpp index b9dcf6554..c5e80f943 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -92,14 +92,14 @@ namespace { struct complete_entry_opt_t { /// Text of the option (like 'foo'). wcstring option; - /// Type of the option: args_only, short, single_long, or double_long. - complete_option_type_t type; /// Arguments to the option. wcstring comp; /// Description of the completion. wcstring desc; /// Conditions under which to use the option. wcstring_list_t conditions; + /// Type of the option: args_only, short, single_long, or double_long. + complete_option_type_t type; /// Determines how completions should be performed on the argument after the switch. completion_mode_t result_mode; /// Completion flags. diff --git a/src/complete.h b/src/complete.h index 2c27e05b4..2ec228585 100644 --- a/src/complete.h +++ b/src/complete.h @@ -198,7 +198,7 @@ class completion_receiver_t { const size_t limit_; }; -enum complete_option_type_t { +enum complete_option_type_t : uint8_t { option_type_args_only, // no option option_type_short, // -x option_type_single_long, // -foo