From 3a9bae6363ee109af0bc7877e53ea747fc1846e0 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 12 Dec 2023 01:18:57 +1000 Subject: [PATCH] cmd: inline Cmd_Arg* helper funcs in all compilation units ea7ad935aa214b3a52eb7079110e992fbfe750ee should have done this. Signed-off-by: bones_was_here --- cmd.c | 32 -------------------------------- cmd.h | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/cmd.c b/cmd.c index c73a7c6e..5315d48d 100644 --- a/cmd.c +++ b/cmd.c @@ -1706,38 +1706,6 @@ void Cmd_Shutdown(void) } } -/* -============ -Cmd_Argc -============ -*/ -inline int Cmd_Argc (cmd_state_t *cmd) -{ - return cmd->argc; -} - -/* -============ -Cmd_Argv -============ -*/ -inline const char *Cmd_Argv(cmd_state_t *cmd, int arg) -{ - if (arg >= cmd->argc ) - return cmd->null_string; - return cmd->argv[arg]; -} - -/* -============ -Cmd_Args -============ -*/ -inline const char *Cmd_Args (cmd_state_t *cmd) -{ - return cmd->args; -} - /* ============ Cmd_TokenizeString diff --git a/cmd.h b/cmd.h index b3502919..a1cd89e7 100644 --- a/cmd.h +++ b/cmd.h @@ -250,15 +250,25 @@ const char *Cmd_CompleteAlias (cmd_state_t *cmd, const char *partial); void Cmd_CompleteAliasPrint (cmd_state_t *cmd, const char *partial); // Enhanced console completion by Fett erich@heintz.com - // Added by EvilTypeGuy eviltypeguy@qeradiant.com -int Cmd_Argc (cmd_state_t *cmd); -const char *Cmd_Argv (cmd_state_t *cmd, int arg); -const char *Cmd_Args (cmd_state_t *cmd); // The functions that execute commands get their parameters with these // functions. Cmd_Argv(cmd, ) will return an empty string, not a NULL // if arg > argc, so string operations are always safe. +static inline int Cmd_Argc (cmd_state_t *cmd) +{ + return cmd->argc; +} +static inline const char *Cmd_Argv(cmd_state_t *cmd, int arg) +{ + if (arg >= cmd->argc ) + return cmd->null_string; + return cmd->argv[arg]; +} +static inline const char *Cmd_Args (cmd_state_t *cmd) +{ + return cmd->args; +} /// Returns the position (1 to argc-1) in the command's argument list /// where the given parameter apears, or 0 if not present -- 2.39.2