Skip to content

Commit

Permalink
] noexcept
Browse files Browse the repository at this point in the history
Summary:
marking noinline functions as noexcept to help compiler optimizations.
I didn't see effect in the microbenchmarks, but should be at least not worse.

Reviewed By: yfeldblum

Differential Revision: D64046213
  • Loading branch information
DenisYaroshevskiy authored and facebook-github-bot committed Oct 11, 2024
1 parent 62d453e commit a3af021
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions folly/algorithm/simd/Contains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@

namespace folly::simd::detail {

bool containsU8(folly::span<const std::uint8_t> haystack, std::uint8_t needle) {
bool containsU8(
folly::span<const std::uint8_t> haystack, std::uint8_t needle) noexcept {
return containsImpl(haystack, needle);
}
bool containsU16(
folly::span<const std::uint16_t> haystack, std::uint16_t needle) {
folly::span<const std::uint16_t> haystack, std::uint16_t needle) noexcept {
return containsImpl(haystack, needle);
}
bool containsU32(
folly::span<const std::uint32_t> haystack, std::uint32_t needle) {
folly::span<const std::uint32_t> haystack, std::uint32_t needle) noexcept {
return containsImpl(haystack, needle);
}

bool containsU64(
folly::span<const std::uint64_t> haystack, std::uint64_t needle) {
folly::span<const std::uint64_t> haystack, std::uint64_t needle) noexcept {
return containsImpl(haystack, needle);
}

Expand Down
9 changes: 5 additions & 4 deletions folly/algorithm/simd/Contains.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ namespace detail {

// no overloading for easier profiling.

bool containsU8(folly::span<const std::uint8_t> haystack, std::uint8_t needle);
bool containsU8(
folly::span<const std::uint8_t> haystack, std::uint8_t needle) noexcept;
bool containsU16(
folly::span<const std::uint16_t> haystack, std::uint16_t needle);
folly::span<const std::uint16_t> haystack, std::uint16_t needle) noexcept;
bool containsU32(
folly::span<const std::uint32_t> haystack, std::uint32_t needle);
folly::span<const std::uint32_t> haystack, std::uint32_t needle) noexcept;
bool containsU64(
folly::span<const std::uint64_t> haystack, std::uint64_t needle);
folly::span<const std::uint64_t> haystack, std::uint64_t needle) noexcept;

template <typename R>
using std_range_value_t = typename std::iterator_traits<decltype(std::begin(
Expand Down

0 comments on commit a3af021

Please sign in to comment.