Fix the test for partition_copy so it is not ridiculously slow. Also, detab.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346104 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2018-11-04 17:57:25 +00:00
parent 048b34a304
commit 9b0b9d6ce6

View File

@@ -222,11 +222,24 @@ int partition_copy(const uint8_t *data, size_t size)
if (!std::none_of(v2.begin(), v2.end(), is_even<uint8_t>())) return 3; if (!std::none_of(v2.begin(), v2.end(), is_even<uint8_t>())) return 3;
// Every value in both vectors has to be in the original // Every value in both vectors has to be in the original
for (auto v: v1)
if (std::find(data, data + size, v) == data + size) return 4;
for (auto v: v2) // Make a copy of the input, and sort it
if (std::find(data, data + size, v) == data + size) return 5; Vec v0{data, data + size};
std::sort(v0.begin(), v0.end());
// Sort each vector and ensure that all of the elements appear in the original input
std::sort(v1.begin(), v1.end());
if (!std::includes(v0.begin(), v0.end(), v1.begin(), v1.end())) return 4;
std::sort(v2.begin(), v2.end());
if (!std::includes(v0.begin(), v0.end(), v2.begin(), v2.end())) return 5;
// This, while simple, is really slow - 20 seconds on a 500K element input.
// for (auto v: v1)
// if (std::find(data, data + size, v) == data + size) return 4;
//
// for (auto v: v2)
// if (std::find(data, data + size, v) == data + size) return 5;
return 0; return 0;
} }