mirror of
https://github.com/NixOS/nix
synced 2025-06-25 19:01:16 +02:00
nix-util: Use small_vector in concatMapStringsSep
This commit is contained in:
parent
f3dbaa3f54
commit
32898dc46a
2 changed files with 5 additions and 1 deletions
|
@ -39,6 +39,7 @@ basicSplitString(std::basic_string_view<OsChar> s, std::basic_string_view<OsChar
|
||||||
template std::string concatStringsSep(std::string_view, const std::list<std::string> &);
|
template std::string concatStringsSep(std::string_view, const std::list<std::string> &);
|
||||||
template std::string concatStringsSep(std::string_view, const std::set<std::string> &);
|
template std::string concatStringsSep(std::string_view, const std::set<std::string> &);
|
||||||
template std::string concatStringsSep(std::string_view, const std::vector<std::string> &);
|
template std::string concatStringsSep(std::string_view, const std::vector<std::string> &);
|
||||||
|
template std::string concatStringsSep(std::string_view, const boost::container::small_vector<std::string, 64> &);
|
||||||
|
|
||||||
typedef std::string_view strings_2[2];
|
typedef std::string_view strings_2[2];
|
||||||
template std::string concatStringsSep(std::string_view, const strings_2 &);
|
template std::string concatStringsSep(std::string_view, const strings_2 &);
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/container/small_vector.hpp>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -54,6 +56,7 @@ std::string concatStringsSep(const std::string_view sep, const C & ss);
|
||||||
extern template std::string concatStringsSep(std::string_view, const std::list<std::string> &);
|
extern template std::string concatStringsSep(std::string_view, const std::list<std::string> &);
|
||||||
extern template std::string concatStringsSep(std::string_view, const std::set<std::string> &);
|
extern template std::string concatStringsSep(std::string_view, const std::set<std::string> &);
|
||||||
extern template std::string concatStringsSep(std::string_view, const std::vector<std::string> &);
|
extern template std::string concatStringsSep(std::string_view, const std::vector<std::string> &);
|
||||||
|
extern template std::string concatStringsSep(std::string_view, const boost::container::small_vector<std::string, 64> &);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a function to the `iterable`'s items and concat them with `separator`.
|
* Apply a function to the `iterable`'s items and concat them with `separator`.
|
||||||
|
@ -61,7 +64,7 @@ extern template std::string concatStringsSep(std::string_view, const std::vector
|
||||||
template<class C, class F>
|
template<class C, class F>
|
||||||
std::string concatMapStringsSep(std::string_view separator, const C & iterable, F fn)
|
std::string concatMapStringsSep(std::string_view separator, const C & iterable, F fn)
|
||||||
{
|
{
|
||||||
std::vector<std::string> strings;
|
boost::container::small_vector<std::string, 64> strings;
|
||||||
strings.reserve(iterable.size());
|
strings.reserve(iterable.size());
|
||||||
for (const auto & elem : iterable) {
|
for (const auto & elem : iterable) {
|
||||||
strings.push_back(fn(elem));
|
strings.push_back(fn(elem));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue