shell: history feature optimization

When history feature is not compiled in it makes no sense to
trim the command. In addition when history feature is not active the
shell will not call function history_put.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2020-11-18 11:57:53 +01:00 committed by Maureen Helm
commit 0e91aada4a

View file

@ -599,10 +599,11 @@ static int execute(const struct shell *shell)
memset(&shell->ctx->active_cmd, 0, sizeof(shell->ctx->active_cmd));
shell_cmd_trim(shell);
history_put(shell, shell->ctx->cmd_buff,
shell->ctx->cmd_buff_len);
if (IS_ENABLED(CONFIG_SHELL_HISTORY)) {
shell_cmd_trim(shell);
history_put(shell, shell->ctx->cmd_buff,
shell->ctx->cmd_buff_len);
}
if (IS_ENABLED(CONFIG_SHELL_WILDCARD)) {
shell_wildcard_prepare(shell);