Skip to content
Snippets Groups Projects
Commit ae76d0c3 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

string_utils: don't copy set in string_join, use {fmt}

Change-Id: Ibab897b53868091e55f092ccf1bc9a016de467b6
parent 3df31d22
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
#include "string_utils.h"
#include <fmt/core.h>
#include <fmt/ranges.h>
#include <sstream>
#include <cctype>
......@@ -146,14 +147,9 @@ string_remove_suffix(std::string_view str, char separator)
}
std::string
string_join(std::set<std::string> set, std::string_view separator)
string_join(const std::set<std::string>& set, std::string_view separator)
{
if (set.empty())
return "";
std::string output;
for (const auto &s : set)
output += s+separator;
return output;
return fmt::format("{}", fmt::join(set, separator));
}
std::set<std::string>
......
......@@ -178,7 +178,7 @@ void string_replace(std::string& str, const std::string& from, const std::string
std::string_view string_remove_suffix(std::string_view str, char separator);
std::string string_join(std::set<std::string> set, std::string_view separator = "/");
std::string string_join(const std::set<std::string>& set, std::string_view separator = "/");
std::set<std::string> string_split_set(std::string& str, std::string_view separator = "/");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment