Auto merge of #1005 - bitcartel:zc.v0.11.2.z4_issue_857_optimize, r=ebfull

Equihash - Optimization to DistinctIndices function (rebased PR)

Update to DistinctIndices function (for issue #857).
Replaces pull request #974.
This commit is contained in:
zkbot 2016-06-09 03:49:22 +00:00
commit b3418be123
1 changed files with 7 additions and 13 deletions

View File

@ -10,20 +10,14 @@
template<size_t WIDTH>
bool DistinctIndices(const FullStepRow<WIDTH>& a, const FullStepRow<WIDTH>& b, size_t len, size_t lenIndices)
{
std::vector<eh_index> aSrt = a.GetIndices(len, lenIndices);
std::vector<eh_index> bSrt = b.GetIndices(len, lenIndices);
std::sort(aSrt.begin(), aSrt.end());
std::sort(bSrt.begin(), bSrt.end());
unsigned int i = 0;
for (unsigned int j = 0; j < bSrt.size(); j++) {
while (aSrt[i] < bSrt[j]) {
i++;
if (i == aSrt.size()) { return true; }
std::vector<eh_index> vIndicesA = a.GetIndices(len, lenIndices);
std::vector<eh_index> vIndicesB = b.GetIndices(len, lenIndices);
for(auto const& value1: vIndicesA) {
for(auto const& value2: vIndicesB) {
if (value1==value2) {
return false;
}
}
assert(aSrt[i] >= bSrt[j]);
if (aSrt[i] == bSrt[j]) { return false; }
}
return true;
}