Skip to content

Commit

Permalink
Fix performance-noexcept-swap clang-tidy warning (#6931)
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou authored Jun 7, 2024
1 parent 523ee76 commit c57b0d2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Checks: >
modernize-use-using,
performance-*,
-performance-noexcept-move-constructor,
-performance-noexcept-swap,
-performance-no-int-to-ptr,
-performance-enum-size,
-performance-avoid-endl,
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- NodeJS:
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
- Misc:
- FIXED: Fix performance-noexcept-swap clang-tidy warning. [#6931](https://github.com/Project-OSRM/osrm-backend/pull/6931)
- CHANGED: Use custom struct instead of std::pair in QueryHeap. [#6921](https://github.com/Project-OSRM/osrm-backend/pull/6921)
- CHANGED: Use std::string_view::starts_with instead of boost::starts_with. [#6918](https://github.com/Project-OSRM/osrm-backend/pull/6918)
- CHANGED: Get rid of boost::math::constants::* and M_PI in favor of std::numbers. [#6916](https://github.com/Project-OSRM/osrm-backend/pull/6916)
Expand Down
9 changes: 5 additions & 4 deletions include/util/deallocating_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class DeallocatingVectorIterator

template <typename ElementT> class DeallocatingVector;

template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs);
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs) noexcept;

template <typename ElementT> class DeallocatingVector
{
Expand Down Expand Up @@ -221,9 +221,10 @@ template <typename ElementT> class DeallocatingVector

~DeallocatingVector() { clear(); }

friend void swap<>(DeallocatingVector<ElementT> &lhs, DeallocatingVector<ElementT> &rhs);
friend void swap<>(DeallocatingVector<ElementT> &lhs,
DeallocatingVector<ElementT> &rhs) noexcept;

void swap(DeallocatingVector<ElementT> &other)
void swap(DeallocatingVector<ElementT> &other) noexcept
{
std::swap(current_size, other.current_size);
bucket_list.swap(other.bucket_list);
Expand Down Expand Up @@ -342,7 +343,7 @@ template <typename ElementT> class DeallocatingVector
}
};

template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs)
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs) noexcept
{
lhs.swap(rhs);
}
Expand Down
4 changes: 2 additions & 2 deletions include/util/permutation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace osrm::util

namespace permutation_detail
{
template <typename T> static inline void swap(T &a, T &b) { std::swap(a, b); }
template <typename T> static inline void swap(T &a, T &b) noexcept { std::swap(a, b); }

static inline void swap(std::vector<bool>::reference a, std::vector<bool>::reference b)
static inline void swap(std::vector<bool>::reference a, std::vector<bool>::reference b) noexcept
{
std::vector<bool>::swap(a, b);
}
Expand Down

0 comments on commit c57b0d2

Please sign in to comment.