better packing for command struct

This moves all the bitfields in struct cmd_list_element to be closer
together.  This packs the structure somewhat better.  On a 64 bit
machine, this simple rearrangement saves around 50k at startup.

2014-01-20  Tom Tromey  <tromey@redhat.com>

	* cli/cli-decode.h (struct cmd_list_element): Move all bitfields
	together.
This commit is contained in:
Tom Tromey 2013-12-26 22:06:27 -07:00
parent 1f2bdf09c6
commit 9ea4267d62
2 changed files with 53 additions and 48 deletions

View File

@ -1,3 +1,8 @@
2014-01-20 Tom Tromey <tromey@redhat.com>
* cli/cli-decode.h (struct cmd_list_element): Move all bitfields
together.
2014-01-20 Tom Tromey <tromey@redhat.com>
* cli/cli-decode.c (add_cmd, deprecate_cmd, add_alias_cmd)

View File

@ -55,6 +55,54 @@ struct cmd_list_element
/* Command class; class values are chosen by application program. */
enum command_class class;
/* When 1 indicated that this command is deprecated. It may be
removed from gdb's command set in the future. */
unsigned int cmd_deprecated : 1;
/* The user needs to be warned that this is a deprecated command.
The user should only be warned the first time a command is
used. */
unsigned int deprecated_warn_user : 1;
/* When functions are deprecated at compile time (this is the way
it should, in general, be done) the memory containing the
replacement string is statically allocated. In some cases it
makes sense to deprecate commands at runtime (the testsuite is
one example). In this case the memory for replacement is
malloc'ed. When a command is undeprecated or re-deprecated at
runtime we don't want to risk calling free on statically
allocated memory, so we check this flag. */
unsigned int malloced_replacement : 1;
/* Set if the doc field should be xfree'd. */
unsigned int doc_allocated : 1;
/* Flag that specifies if this command is already running its hook. */
/* Prevents the possibility of hook recursion. */
unsigned int hook_in : 1;
/* For prefix commands only:
nonzero means do not get an error if subcommand is not
recognized; call the prefix's own function in that case. */
unsigned int allow_unknown : 1;
/* Nonzero says this is an abbreviation, and should not
be mentioned in lists of commands.
This allows "br<tab>" to complete to "break", which it
otherwise wouldn't. */
unsigned int abbrev_flag : 1;
/* Type of "set" or "show" command (or SET_NOT_SET if not "set"
or "show"). */
ENUM_BITFIELD (cmd_types) type : 2;
/* What kind of variable is *VAR? */
ENUM_BITFIELD (var_types) var_type : 4;
/* Function definition of this command. NULL for command class
names and for help topics that are not really commands. NOTE:
cagney/2002-02-02: This function signature is evolving. For
@ -86,32 +134,6 @@ struct cmd_list_element
specified stream. */
show_value_ftype *show_value_func;
/* When 1 indicated that this command is deprecated. It may be
removed from gdb's command set in the future. */
unsigned int cmd_deprecated : 1;
/* The user needs to be warned that this is a deprecated command.
The user should only be warned the first time a command is
used. */
unsigned int deprecated_warn_user : 1;
/* When functions are deprecated at compile time (this is the way
it should, in general, be done) the memory containing the
replacement string is statically allocated. In some cases it
makes sense to deprecate commands at runtime (the testsuite is
one example). In this case the memory for replacement is
malloc'ed. When a command is undeprecated or re-deprecated at
runtime we don't want to risk calling free on statically
allocated memory, so we check this flag. */
unsigned int malloced_replacement : 1;
/* Set if the doc field should be xfree'd. */
unsigned int doc_allocated : 1;
/* If this command is deprecated, this is the replacement name. */
char *replacement;
@ -122,10 +144,6 @@ struct cmd_list_element
/* Hook for another command to be executed before this command. */
struct cmd_list_element *hook_pre;
/* Flag that specifies if this command is already running its hook. */
/* Prevents the possibility of hook recursion. */
unsigned int hook_in : 1;
/* Hook for another command to be executed after this command. */
struct cmd_list_element *hook_post;
@ -140,20 +158,9 @@ struct cmd_list_element
commands reached through this prefix. */
char *prefixname;
/* For prefix commands only:
nonzero means do not get an error if subcommand is not
recognized; call the prefix's own function in that case. */
unsigned int allow_unknown : 1;
/* The prefix command of this command. */
struct cmd_list_element *prefix;
/* Nonzero says this is an abbreviation, and should not
be mentioned in lists of commands.
This allows "br<tab>" to complete to "break", which it
otherwise wouldn't. */
unsigned int abbrev_flag : 1;
/* Completion routine for this command. TEXT is the text beyond
what was matched for the command itself (leading whitespace is
skipped). It stops where we are supposed to stop completing
@ -174,17 +181,10 @@ struct cmd_list_element
used to finalize the CONTEXT field, if needed. */
void (*destroyer) (struct cmd_list_element *self, void *context);
/* Type of "set" or "show" command (or SET_NOT_SET if not "set"
or "show"). */
ENUM_BITFIELD (cmd_types) type : 2;
/* Pointer to variable affected by "set" and "show". Doesn't
matter if type is not_set. */
void *var;
/* What kind of variable is *VAR? */
ENUM_BITFIELD (var_types) var_type : 4;
/* Pointer to NULL terminated list of enumerated values (like
argv). */
const char *const *enums;