client/Process: reset the CommandListBuilder before processing it

Allows removing a CommandResult::CLOSE check.
This commit is contained in:
Max Kellermann 2019-04-03 22:38:26 +02:00
parent 7d1db5c19f
commit c1272c72b0
2 changed files with 5 additions and 10 deletions

View File

@ -93,24 +93,19 @@ Client::ProcessLine(char *line) noexcept
"[%u] process command list", "[%u] process command list",
num); 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)); std::move(list));
FormatDebug(client_domain, FormatDebug(client_domain,
"[%u] process command " "[%u] process command "
"list returned %i", num, int(ret)); "list returned %i", num, int(ret));
if (ret == CommandResult::CLOSE)
return CommandResult::CLOSE;
assert(!IsExpired());
if (ret == CommandResult::OK) if (ret == CommandResult::OK)
command_success(*this); command_success(*this);
cmd_list.Reset();
return ret; return ret;
} else { } else {
if (!cmd_list.Add(line)) { if (!cmd_list.Add(line)) {

View File

@ -97,7 +97,7 @@ public:
/** /**
* Finishes the list and returns it. * Finishes the list and returns it.
*/ */
std::list<std::string> &&Commit() { std::list<std::string> Commit() {
assert(IsActive()); assert(IsActive());
return std::move(list); return std::move(list);