From c57b0d28b0653def12aa28b957ab70da18e66a4f Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Fri, 7 Jun 2024 16:18:10 +0200 Subject: [PATCH] Fix performance-noexcept-swap clang-tidy warning (#6931) --- .clang-tidy | 1 - CHANGELOG.md | 1 + include/util/deallocating_vector.hpp | 9 +++++---- include/util/permutation.hpp | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 897057abf..bf42711fb 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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, diff --git a/CHANGELOG.md b/CHANGELOG.md index ed478ba28..63323a56c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/include/util/deallocating_vector.hpp b/include/util/deallocating_vector.hpp index 9cb5641e3..f1cb0033d 100644 --- a/include/util/deallocating_vector.hpp +++ b/include/util/deallocating_vector.hpp @@ -166,7 +166,7 @@ class DeallocatingVectorIterator template class DeallocatingVector; -template void swap(DeallocatingVector &lhs, DeallocatingVector &rhs); +template void swap(DeallocatingVector &lhs, DeallocatingVector &rhs) noexcept; template class DeallocatingVector { @@ -221,9 +221,10 @@ template class DeallocatingVector ~DeallocatingVector() { clear(); } - friend void swap<>(DeallocatingVector &lhs, DeallocatingVector &rhs); + friend void swap<>(DeallocatingVector &lhs, + DeallocatingVector &rhs) noexcept; - void swap(DeallocatingVector &other) + void swap(DeallocatingVector &other) noexcept { std::swap(current_size, other.current_size); bucket_list.swap(other.bucket_list); @@ -342,7 +343,7 @@ template class DeallocatingVector } }; -template void swap(DeallocatingVector &lhs, DeallocatingVector &rhs) +template void swap(DeallocatingVector &lhs, DeallocatingVector &rhs) noexcept { lhs.swap(rhs); } diff --git a/include/util/permutation.hpp b/include/util/permutation.hpp index ae046b014..34520389a 100644 --- a/include/util/permutation.hpp +++ b/include/util/permutation.hpp @@ -10,9 +10,9 @@ namespace osrm::util namespace permutation_detail { -template static inline void swap(T &a, T &b) { std::swap(a, b); } +template static inline void swap(T &a, T &b) noexcept { std::swap(a, b); } -static inline void swap(std::vector::reference a, std::vector::reference b) +static inline void swap(std::vector::reference a, std::vector::reference b) noexcept { std::vector::swap(a, b); }