Skip to content

Commit d5f4f19

Browse files
Reduce vector algorithms test run time with ASan (#5425)
Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent 60e7b47 commit d5f4f19

File tree

1 file changed

+22
-4
lines changed
  • tests/std/tests/VSO_0000000_vector_algorithms

1 file changed

+22
-4
lines changed

tests/std/tests/VSO_0000000_vector_algorithms/test.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,19 @@ auto last_known_good_find_first_of(FwdItH h_first, FwdItH h_last, FwdItN n_first
271271

272272
template <class RanItH, class RanItN>
273273
auto last_known_good_search(RanItH h_first, RanItH h_last, RanItN n_first, RanItN n_last) {
274-
const auto n_len = n_last - n_first;
274+
const ptrdiff_t n_len = n_last - n_first;
275275

276276
for (; h_last - h_first >= n_len; ++h_first) {
277-
if (equal(h_first, h_first + n_len, n_first, n_last)) {
277+
bool is_equal = true;
278+
279+
for (ptrdiff_t i = 0; i != n_len; ++i) {
280+
if (*(h_first + i) != *(n_first + i)) {
281+
is_equal = false;
282+
break;
283+
}
284+
}
285+
286+
if (is_equal) {
278287
return h_first;
279288
}
280289
}
@@ -284,7 +293,7 @@ auto last_known_good_search(RanItH h_first, RanItH h_last, RanItN n_first, RanIt
284293

285294
template <class RanItH, class RanItN>
286295
auto last_known_good_find_end(RanItH h_first, RanItH h_last, RanItN n_first, RanItN n_last) {
287-
const auto n_len = n_last - n_first;
296+
const ptrdiff_t n_len = n_last - n_first;
288297

289298
if (n_len > h_last - h_first) {
290299
return h_last;
@@ -293,7 +302,16 @@ auto last_known_good_find_end(RanItH h_first, RanItH h_last, RanItN n_first, Ran
293302
auto h_mid = h_last - n_len;
294303

295304
for (;;) {
296-
if (equal(h_mid, h_mid + n_len, n_first, n_last)) {
305+
bool is_equal = true;
306+
307+
for (ptrdiff_t i = 0; i != n_len; ++i) {
308+
if (*(h_mid + i) != *(n_first + i)) {
309+
is_equal = false;
310+
break;
311+
}
312+
}
313+
314+
if (is_equal) {
297315
return h_mid;
298316
}
299317

0 commit comments

Comments
 (0)