chore: Refactor string span management (#3165)

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2024-06-18 10:37:32 +03:00 committed by GitHub
parent 6291c04016
commit e45c1e92a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 198 additions and 273 deletions

View file

@ -775,13 +775,13 @@ OpResult<vector<StringVec>> OpObjKeys(const OpArgs& op_args, string_view key,
// Retruns array of string lengths after a successful operation.
OpResult<vector<OptSizeT>> OpStrAppend(const OpArgs& op_args, string_view key, string_view path,
JsonPathV2 expression, const vector<string_view>& strs) {
JsonPathV2 expression, facade::ArgRange strs) {
vector<OptSizeT> vec;
OpStatus status;
auto cb = [&](const auto&, JsonType* val) {
if (val->is_string()) {
string new_val = val->as_string();
for (auto& str : strs) {
for (string_view str : strs) {
new_val += str;
}
@ -1822,14 +1822,11 @@ void JsonFamily::StrAppend(CmdArgList args, ConnectionContext* cntx) {
string_view path = ArgS(args, 1);
JsonPathV2 expression = PARSE_PATHV2(path);
vector<string_view> strs;
for (size_t i = 2; i < args.size(); ++i) {
strs.emplace_back(ArgS(args, i));
}
auto strs = args.subspan(2);
auto cb = [&](Transaction* t, EngineShard* shard) {
return OpStrAppend(t->GetOpArgs(shard), key, path, std::move(expression), strs);
return OpStrAppend(t->GetOpArgs(shard), key, path, std::move(expression),
facade::ArgRange{strs});
};
Transaction* trans = cntx->transaction;