From: Martin Kronbichler Date: Fri, 30 Jun 2023 09:45:02 +0000 (+0200) Subject: Simplify IndexSet::add_index() X-Git-Tag: relicensing~841^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd9a77b157131918ca69ccb16be9f80616e36bb6;p=dealii.git Simplify IndexSet::add_index() --- diff --git a/include/deal.II/base/index_set.h b/include/deal.II/base/index_set.h index 155221c91b..c9abbddc7a 100644 --- a/include/deal.II/base/index_set.h +++ b/include/deal.II/base/index_set.h @@ -1686,16 +1686,7 @@ IndexSet::compress() const inline void IndexSet::add_index(const size_type index) { - AssertIndexRange(index, index_space_size); - - const Range new_range(index, index + 1); - if (ranges.size() == 0 || index > ranges.back().end) - ranges.push_back(new_range); - else if (index == ranges.back().end) - ranges.back().end++; - else - add_range_lower_bound(new_range); - is_compressed = false; + add_range(index, index + 1); } @@ -1712,16 +1703,14 @@ IndexSet::add_range(const size_type begin, const size_type end) if (begin != end) { - const Range new_range(begin, end); - // the new index might be larger than the last index present in the // ranges. Then we can skip the binary search if (ranges.size() == 0 || begin > ranges.back().end) - ranges.push_back(new_range); + ranges.emplace_back(begin, end); else if (begin == ranges.back().end) ranges.back().end = end; else - add_range_lower_bound(new_range); + add_range_lower_bound(Range(begin, end)); is_compressed = false; }