Skip to content

Commit

Permalink
Adjust comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Dec 13, 2023
1 parent f1871ca commit 8f1ddf7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/verticalaligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void SystemAligner::ReorderBy(const std::vector<int> &staffNs)
std::sort(order.begin(), order.end());
order.erase(std::unique(order.begin(), order.end()), order.end());
// If not, we should return because the re-ordering below will corrupt the data
// Returning will keep the order as it is
if (order.size() != staffNs.size()) return;

ArrayOfObjects &children = this->GetChildrenForModification();
Expand All @@ -108,12 +109,13 @@ void SystemAligner::ReorderBy(const std::vector<int> &staffNs)
ListOfObjects orderedAlignments;
for (auto staffN : staffNs) {
StaffAlignment *alignment = this->GetStaffAlignmentForStaffN(staffN);
if (!alignment) return;
// Something is wrong in the data, we keep the order as it is
if (!alignment) return;
orderedAlignments.push_back(alignment);
}
int i = 0;
// We know that
// Since the number of staffAlignment is the same and they are unique, we can
// blindly replace them in the StaffAligner children
for (auto alignment : orderedAlignments) {
children.at(i) = alignment;
++i;
Expand Down

0 comments on commit 8f1ddf7

Please sign in to comment.