From 574f0bca7790d00fdcc1dd0bc1758e034e2811ae Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 8 Jun 2016 23:20:54 +0800 Subject: [PATCH 1/2] Update to DistinctIndices function (for issue #857). Replaces pull request #974. --- src/crypto/equihash.tcc | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/crypto/equihash.tcc b/src/crypto/equihash.tcc index e3ad9858c..5986eeb98 100644 --- a/src/crypto/equihash.tcc +++ b/src/crypto/equihash.tcc @@ -12,18 +12,12 @@ bool DistinctIndices(const FullStepRow& a, const FullStepRow& b, s { std::vector aSrt = a.GetIndices(len, lenIndices); std::vector 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; } + for(auto const& value1: aSrt) { + for(auto const& value2: bSrt) { + if (value1==value2) { + return false; + } } - assert(aSrt[i] >= bSrt[j]); - if (aSrt[i] == bSrt[j]) { return false; } } return true; } From dca3af5bde616faf14c0b7a3354535b36e3b4489 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 9 Jun 2016 07:23:33 +0800 Subject: [PATCH 2/2] Update variable name. --- src/crypto/equihash.tcc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crypto/equihash.tcc b/src/crypto/equihash.tcc index 5986eeb98..f10fe2ced 100644 --- a/src/crypto/equihash.tcc +++ b/src/crypto/equihash.tcc @@ -10,10 +10,10 @@ template bool DistinctIndices(const FullStepRow& a, const FullStepRow& b, size_t len, size_t lenIndices) { - std::vector aSrt = a.GetIndices(len, lenIndices); - std::vector bSrt = b.GetIndices(len, lenIndices); - for(auto const& value1: aSrt) { - for(auto const& value2: bSrt) { + std::vector vIndicesA = a.GetIndices(len, lenIndices); + std::vector vIndicesB = b.GetIndices(len, lenIndices); + for(auto const& value1: vIndicesA) { + for(auto const& value2: vIndicesB) { if (value1==value2) { return false; }