From e999c1e339b540bff025ce42904a7a5b7251117e Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 5 Aug 2016 22:12:50 +1200 Subject: [PATCH] Simplify IsProbablyDuplicate() --- src/crypto/equihash.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp index 9c018d72f..3706b0c9e 100644 --- a/src/crypto/equihash.cpp +++ b/src/crypto/equihash.cpp @@ -307,23 +307,21 @@ template bool IsProbablyDuplicate(std::shared_ptr indices, size_t lenIndices) { bool checked_index[MAX_INDICES] = {false}; + bool count_checked = 0; for (int z = 0; z < lenIndices; z++) { + // Skip over indices we have already paired if (!checked_index[z]) { for (int y = z+1; y < lenIndices; y++) { if (!checked_index[y] && indices.get()[z] == indices.get()[y]) { // Pair found checked_index[y] = true; - checked_index[z] = true; + count_checked += 2; break; } } } } - bool is_probably_duplicate = true; - for (int z = 0; z < lenIndices && is_probably_duplicate; z++) { - is_probably_duplicate &= checked_index[z]; - } - return is_probably_duplicate; + return count_checked == lenIndices; } template