mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-22 18:32:16 +00:00
std::set_union expects its inputs to be sorted. (#13928)
This commit is contained in:
@@ -3299,7 +3299,19 @@ static std::vector<std::string> intersect(std::vector<std::string> const& l, std
|
||||
static std::vector<std::string> concat(std::vector<std::string> const& l, std::vector<std::string> const& r)
|
||||
{
|
||||
std::vector<std::string> t;
|
||||
std::set_union(l.begin(), l.end(), r.begin(), r.end(), std::back_inserter(t));
|
||||
bool l_is_sorted = std::is_sorted(l.begin(), l.end());
|
||||
bool r_is_sorted = std::is_sorted(r.begin(), r.end());
|
||||
|
||||
if (l_is_sorted && r_is_sorted) {
|
||||
std::set_union(l.begin(), l.end(), r.begin(), r.end(), std::back_inserter(t));
|
||||
return t;
|
||||
}
|
||||
|
||||
std::vector<std::string> l_sorted = l;
|
||||
std::vector<std::string> r_sorted = r;
|
||||
std::sort(l_sorted.begin(), l_sorted.end());
|
||||
std::sort(r_sorted.begin(), r_sorted.end());
|
||||
std::set_union(l_sorted.begin(), l_sorted.end(), r_sorted.begin(), r_sorted.end(), std::back_inserter(t));
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user