Skip to content

Commit 16ff469

Browse files
authored
includes benchmark: handle edge case simpler (#5595)
1 parent a1f193d commit 16ff469

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmarks/src/includes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <cstdint>
88
#include <cstdlib>
99
#include <iostream>
10+
#include <limits>
1011
#include <random>
1112
#include <ranges>
1213
#include <type_traits>
@@ -74,9 +75,8 @@ void bm_includes(benchmark::State& state) {
7475

7576
if (!expected_match) {
7677
const T v = needle[needle_size / 2];
77-
const T r = static_cast<T>(static_cast<make_unsigned_t<T>>(v) + 1);
78+
const T r = v != numeric_limits<T>::max() ? v + 1 : v - 1;
7879
ranges::replace(hay, v, r);
79-
ranges::sort(hay);
8080
}
8181

8282
for (auto _ : state) {

0 commit comments

Comments
 (0)