Skip to content

Commit

Permalink
Merge pull request #899 from acts-project/perf/simplify_advance
Browse files Browse the repository at this point in the history
Simplify random access iterator advancement
  • Loading branch information
stephenswat authored Dec 9, 2024
2 parents 60e0495 + 054f5d1 commit cefce90
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions core/include/detray/utils/ranges/detail/iterator_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ DETRAY_HOST_DEVICE constexpr void advance_impl(
}
}

// random access iterators specialization
// bidirectional iterators specialization
template <std::bidirectional_iterator iterator_t, typename dist_t>
DETRAY_HOST_DEVICE constexpr void advance_impl(
iterator_t& itr, dist_t d, detray::ranges::bidirectional_iterator_tag) {
Expand All @@ -152,17 +152,7 @@ template <std::random_access_iterator iterator_t, typename dist_t>
DETRAY_HOST_DEVICE constexpr void advance_impl(
iterator_t& itr, dist_t d, detray::ranges::random_access_iterator_tag) {
static_assert(std::is_integral_v<dist_t>);
if (d == static_cast<dist_t>(1)) {
++itr;
} else {
if constexpr (std::is_signed_v<dist_t>) {
if (d == static_cast<dist_t>(-1)) {
--itr;
return;
}
}
itr += d;
}
itr += d;
}

template <std::input_iterator iterator_t, typename dist_t>
Expand Down

0 comments on commit cefce90

Please sign in to comment.