Use adjacent_find to check adjacent parts

This commit is contained in:
Alexander Gololobov 2024-09-17 17:56:44 +02:00
parent 3674c97ebb
commit 574a26c63b

View File

@ -917,18 +917,15 @@ void InOrderCoordinator<mode>::doHandleInitialAllRangesAnnouncement(InitialAllRa
#ifndef NDEBUG #ifndef NDEBUG
/// Double check that there are no intersecting parts /// Double check that there are no intersecting parts
{ {
auto part_it = all_parts_to_read.begin(); auto intersecting_part_it = std::adjacent_find(all_parts_to_read.begin(), all_parts_to_read.end(),
auto next_part_it = part_it; [] (const Part & lhs, const Part & rhs)
if (next_part_it != all_parts_to_read.end()) {
++next_part_it; return !lhs.description.info.isDisjoint(rhs.description.info);
while (next_part_it != all_parts_to_read.end()) });
{
chassert(part_it->description.info.isDisjoint(next_part_it->description.info), if (intersecting_part_it != all_parts_to_read.end())
fmt::format("Parts {} and {} intersect", throw Exception(ErrorCodes::LOGICAL_ERROR, "Parts {} and {} intersect",
part_it->description.info.getPartNameV1(), next_part_it->description.info.getPartNameV1())); intersecting_part_it->description.info.getPartNameV1(), std::next(intersecting_part_it)->description.info.getPartNameV1());
++part_it;
++next_part_it;
}
} }
#endif #endif