@@ -1423,16 +1423,16 @@ std::optional<ErrorReply> Service::VerifyCommandState(const CommandId* cid, CmdA
14231423 return VerifyConnectionAclStatus (cid, &dfly_cntx, " has no ACL permissions" , tail_args);
14241424}
14251425
1426- DispatchResult Service::DispatchCommand (ArgSlice args, SinkReplyBuilder* builder,
1426+ DispatchResult Service::DispatchCommand (facade::ParsedArgs args, SinkReplyBuilder* builder,
14271427 facade::ConnectionContext* cntx) {
14281428 DCHECK (!args.empty ());
14291429 DCHECK_NE (0u , shard_set->size ()) << " Init was not called" ;
14301430
14311431 absl::Cleanup clear_last_error ([builder]() { builder->ConsumeLastError (); });
14321432 ServerState& etl = *ServerState::tlocal ();
14331433
1434- string cmd = absl::AsciiStrToUpper (args[ 0 ] );
1435- const auto [cid, args_no_cmd] = registry_.FindExtended (cmd, args.subspan ( 1 ));
1434+ string cmd = absl::AsciiStrToUpper (args. Front () );
1435+ const auto [cid, args_no_cmd] = registry_.FindExtended (cmd, args.Tail ( ));
14361436
14371437 if (cid == nullptr ) {
14381438 builder->SendError (ReportUnknownCmd (cmd));
@@ -1446,7 +1446,7 @@ DispatchResult Service::DispatchCommand(ArgSlice args, SinkReplyBuilder* builder
14461446
14471447 if (VLOG_IS_ON (2 ) && cntx->conn () /* no owner in replica context */ ) {
14481448 LOG (INFO) << " Got (" << cntx->conn ()->GetClientId () << " ): " << (under_script ? " LUA " : " " )
1449- << args << " in dbid=" << dfly_cntx->conn_state .db_index ;
1449+ << args. ToSlice () << " in dbid=" << dfly_cntx->conn_state .db_index ;
14501450 }
14511451
14521452 // Don't interrupt running multi commands or admin connections.
@@ -1460,7 +1460,8 @@ DispatchResult Service::DispatchCommand(ArgSlice args, SinkReplyBuilder* builder
14601460 cntx->paused = false ;
14611461 }
14621462
1463- if (auto err = VerifyCommandState (cid, args_no_cmd, *dfly_cntx); err) {
1463+ auto tail_args = args_no_cmd.ToSlice ();
1464+ if (auto err = VerifyCommandState (cid, tail_args, *dfly_cntx); err) {
14641465 LOG_IF (WARNING, cntx->replica_conn || !cntx->conn () /* no owner in replica context */ )
14651466 << " VerifyCommandState error: " << err->ToSv ();
14661467 if (auto & exec_info = dfly_cntx->conn_state .exec_info ; exec_info.IsCollecting ())
@@ -1469,7 +1470,7 @@ DispatchResult Service::DispatchCommand(ArgSlice args, SinkReplyBuilder* builder
14691470 // We need to skip this because ACK's should not be replied to
14701471 // Bonus points because this allows to continue replication with ACL users who got
14711472 // their access revoked and reinstated
1472- if (cid->name () == " REPLCONF" && absl::EqualsIgnoreCase (ArgS ( args_no_cmd, 0 ), " ACK" )) {
1473+ if (cid->name () == " REPLCONF" && absl::EqualsIgnoreCase (args_no_cmd. Front ( ), " ACK" )) {
14731474 server_family_.GetDflyCmd ()->OnClose (dfly_cntx->conn_state .replication_info .repl_session_id );
14741475 return DispatchResult::ERROR;
14751476 }
@@ -1486,7 +1487,7 @@ DispatchResult Service::DispatchCommand(ArgSlice args, SinkReplyBuilder* builder
14861487 // TODO: protect against aggregating huge transactions.
14871488 auto & exec_info = dfly_cntx->conn_state .exec_info ;
14881489 const size_t old_size = exec_info.GetStoredCmdBytes ();
1489- exec_info.AddStoredCmd (cid, true , args_no_cmd );
1490+ exec_info.AddStoredCmd (cid, true , tail_args );
14901491 etl.stats .stored_cmd_bytes += exec_info.GetStoredCmdBytes () - old_size;
14911492 if (cid->IsWriteOnly ()) {
14921493 exec_info.is_write = true ;
@@ -1503,7 +1504,7 @@ DispatchResult Service::DispatchCommand(ArgSlice args, SinkReplyBuilder* builder
15031504 if (cid->IsTransactional ()) {
15041505 dfly_cntx->transaction ->MultiSwitchCmd (cid);
15051506 OpStatus status = dfly_cntx->transaction ->InitByArgs (
1506- dfly_cntx->ns , dfly_cntx->conn_state .db_index , args_no_cmd );
1507+ dfly_cntx->ns , dfly_cntx->conn_state .db_index , tail_args );
15071508
15081509 if (status != OpStatus::OK) {
15091510 builder->SendError (status);
@@ -1519,7 +1520,7 @@ DispatchResult Service::DispatchCommand(ArgSlice args, SinkReplyBuilder* builder
15191520 if (!dist_trans->IsMulti ()) { // Multi command initialize themself based on their mode.
15201521 CHECK (dfly_cntx->ns != nullptr );
15211522 if (auto st =
1522- dist_trans->InitByArgs (dfly_cntx->ns , dfly_cntx->conn_state .db_index , args_no_cmd );
1523+ dist_trans->InitByArgs (dfly_cntx->ns , dfly_cntx->conn_state .db_index , tail_args );
15231524 st != OpStatus::OK) {
15241525 builder->SendError (st);
15251526 return DispatchResult::ERROR;
@@ -1535,8 +1536,7 @@ DispatchResult Service::DispatchCommand(ArgSlice args, SinkReplyBuilder* builder
15351536
15361537 dfly_cntx->cid = cid;
15371538
1538- auto res =
1539- InvokeCmd (cid, args_no_cmd, CommandContext{dfly_cntx->transaction , builder, dfly_cntx});
1539+ auto res = InvokeCmd (cid, tail_args, CommandContext{dfly_cntx->transaction , builder, dfly_cntx});
15401540 if ((res != DispatchResult::OK) && (res != DispatchResult::OOM)) {
15411541 builder->SendError (" Internal Error" );
15421542 builder->CloseConnection ();
@@ -1722,7 +1722,7 @@ DispatchResult Service::InvokeCmd(const CommandId* cid, CmdArgList tail_args,
17221722 return res;
17231723}
17241724
1725- DispatchManyResult Service::DispatchManyCommands (absl::Span<CmdArgList > args_list,
1725+ DispatchManyResult Service::DispatchManyCommands (absl::Span<facade::ParsedArgs > args_list,
17261726 SinkReplyBuilder* builder,
17271727 facade::ConnectionContext* cntx) {
17281728 ConnectionContext* dfly_cntx = static_cast <ConnectionContext*>(cntx);
@@ -1768,9 +1768,9 @@ DispatchManyResult Service::DispatchManyCommands(absl::Span<CmdArgList> args_lis
17681768 stored_cmds.clear ();
17691769 };
17701770
1771- for (auto args : args_list) {
1772- string cmd = absl::AsciiStrToUpper (ArgS ( args, 0 ));
1773- const auto [cid, tail_args] = registry_.FindExtended (cmd, args.subspan ( 1 ));
1771+ for (const auto & args : args_list) {
1772+ string cmd = absl::AsciiStrToUpper (args. Front ( ));
1773+ const auto [cid, tail_args] = registry_.FindExtended (cmd, args.Tail ( ));
17741774
17751775 // MULTI...EXEC commands need to be collected into a single context, so squashing is not
17761776 // possible
@@ -1787,7 +1787,7 @@ DispatchManyResult Service::DispatchManyCommands(absl::Span<CmdArgList> args_lis
17871787
17881788 if (!is_multi && !is_eval && !is_blocking && cid != nullptr ) {
17891789 stored_cmds.reserve (args_list.size ());
1790- stored_cmds.emplace_back (cid, false /* do not deep-copy commands*/ , tail_args);
1790+ stored_cmds.emplace_back (cid, false /* do not deep-copy commands*/ , tail_args. ToSlice () );
17911791 continue ;
17921792 }
17931793
@@ -1945,7 +1945,7 @@ void Service::DispatchMC(const MemcacheParser::Command& cmd, std::string_view va
19451945 }
19461946 }
19471947
1948- DispatchCommand (CmdArgList {args}, mc_builder, cntx);
1948+ DispatchCommand (ParsedArgs {args}, mc_builder, cntx);
19491949
19501950 // Reset back.
19511951 dfly_cntx->conn_state .memcache_flag = 0 ;
0 commit comments