Skip to content

Commit d3fc097

Browse files
committed
pattern: Fix dynamic arrays not sorting its children
1 parent b59daf1 commit d3fc097

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/include/pl/patterns/pattern_array_dynamic.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ namespace pl::ptrn {
1313

1414
PatternArrayDynamic(const PatternArrayDynamic &other) : Pattern(other) {
1515
std::vector<std::shared_ptr<Pattern>> entries;
16+
entries.reserve(other.m_entries.size());
1617
for (const auto &entry : other.m_entries)
1718
entries.push_back(entry->clone());
1819

19-
this->setEntries(entries);
20+
PatternArrayDynamic::setEntries(entries);
2021
}
2122

2223
[[nodiscard]] std::shared_ptr<Pattern> clone() const override {
@@ -76,7 +77,7 @@ namespace pl::ptrn {
7677

7778
for (const auto &entry : this->m_entries) {
7879
auto children = entry->getChildren();
79-
std::move(children.begin(), children.end(), std::back_inserter(result));
80+
std::ranges::move(children, std::back_inserter(result));
8081
}
8182

8283
return result;
@@ -132,6 +133,11 @@ namespace pl::ptrn {
132133
}
133134
}
134135

136+
void sort(const std::function<bool (const Pattern *, const Pattern *)> &comparator) override {
137+
for (auto &member : this->m_entries)
138+
member->sort(comparator);
139+
}
140+
135141
void addEntry(const std::shared_ptr<Pattern> &entry) override {
136142
if (entry == nullptr) return;
137143

0 commit comments

Comments
 (0)