From cd05f6160723a723b14efa2012e8bb1bfdd6d12b Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 5 Oct 2024 20:54:11 +0800 Subject: [PATCH] api/storage_service: use ranges when handlging restore API this change is a follow up of 787ea4b1, to modernize the code base. Signed-off-by: Kefu Chai Closes scylladb/scylladb#20972 --- api/storage_service.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/storage_service.cc b/api/storage_service.cc index 5d290d0237..7af87282c8 100644 --- a/api/storage_service.cc +++ b/api/storage_service.cc @@ -505,10 +505,9 @@ void set_sstables_loader(http_context& ctx, routes& r, sharded& if (!parsed.IsArray()) { throw httpd::bad_param_exception("mulformatted sstables in body"); } - std::vector sstables; - for (const rjson::value& element : parsed.GetArray()) { - sstables.emplace_back(rjson::to_string_view(element)); - } + auto sstables = parsed.GetArray() | + std::views::transform([] (const auto& s) { return sstring(rjson::to_string_view(s)); }) | + std::ranges::to(); auto task_id = co_await sst_loader.local().download_new_sstables(keyspace, table, prefix, std::move(sstables), endpoint, bucket); co_return json::json_return_type(fmt::to_string(task_id)); });