From c1272c72b06cf80e43dcd94b3e765fef35e05f60 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 3 Apr 2019 22:38:26 +0200 Subject: [PATCH] client/Process: reset the CommandListBuilder before processing it Allows removing a CommandResult::CLOSE check. --- src/client/Process.cxx | 13 ++++--------- src/command/CommandListBuilder.hxx | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/client/Process.cxx b/src/client/Process.cxx index cf6ed885b..7cd25348e 100644 --- a/src/client/Process.cxx +++ b/src/client/Process.cxx @@ -93,24 +93,19 @@ Client::ProcessLine(char *line) noexcept "[%u] process command list", num); - auto &&list = cmd_list.Commit(); + const bool ok_mode = cmd_list.IsOKMode(); + auto list = cmd_list.Commit(); + cmd_list.Reset(); - auto ret = ProcessCommandList(cmd_list.IsOKMode(), + auto ret = ProcessCommandList(ok_mode, std::move(list)); FormatDebug(client_domain, "[%u] process command " "list returned %i", num, int(ret)); - if (ret == CommandResult::CLOSE) - return CommandResult::CLOSE; - - assert(!IsExpired()); - if (ret == CommandResult::OK) command_success(*this); - cmd_list.Reset(); - return ret; } else { if (!cmd_list.Add(line)) { diff --git a/src/command/CommandListBuilder.hxx b/src/command/CommandListBuilder.hxx index 87cdee6f0..9513f1bb5 100644 --- a/src/command/CommandListBuilder.hxx +++ b/src/command/CommandListBuilder.hxx @@ -97,7 +97,7 @@ public: /** * Finishes the list and returns it. */ - std::list &&Commit() { + std::list Commit() { assert(IsActive()); return std::move(list);