Remove cmd name from args (#1057)

chore: remove cmd name from the list of arguments

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Co-authored-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Vladislav 2023-04-10 14:14:52 +03:00 committed by GitHub
parent 8600eacdc4
commit a12ddfe108
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 564 additions and 573 deletions

View file

@ -32,18 +32,7 @@ void JournalWriter::Write(std::string_view sv) {
sink_->Write(io::Buffer(sv));
}
void JournalWriter::Write(CmdArgList args) {
Write(args.size());
size_t cmd_size = 0;
for (auto v : args) {
cmd_size += v.size();
}
Write(cmd_size);
for (auto v : args)
Write(facade::ToSV(v));
}
void JournalWriter::Write(std::pair<std::string_view, ArgSlice> args) {
template <typename C> void JournalWriter::Write(std::pair<std::string_view, C> args) {
auto [cmd, tail_args] = args;
Write(1 + tail_args.size());
@ -55,10 +44,17 @@ void JournalWriter::Write(std::pair<std::string_view, ArgSlice> args) {
Write(cmd_size);
Write(cmd);
for (auto v : tail_args)
Write(v);
for (auto v : tail_args) {
if constexpr (is_same_v<C, CmdArgList>)
Write(facade::ToSV(v));
else
Write(v);
}
}
template void JournalWriter::Write(pair<string_view, CmdArgList>);
template void JournalWriter::Write(pair<string_view, ArgSlice>);
void JournalWriter::Write(std::monostate) {
}