From 6b64964ba7ac779a444c6fa13fc618420ae77aa1 Mon Sep 17 00:00:00 2001 From: who-biz <37732338+who-biz@users.noreply.github.com> Date: Mon, 22 Jun 2020 17:50:04 -0400 Subject: [PATCH] Simplify dynamic section of algorithm - Should result in a slight speedup for mining/verification --- src/cryptonote_basic/cryptonote_format_utils.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index 73720dcb..34a7866b 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -944,17 +944,13 @@ namespace cryptonote } else if (b.major_version >= 10) { - // get 6 char from previous hash as varint - epee::span span_bytes = epee::as_byte_span(b.prev_id); - - uint8_t i = 0; - subhash sub; sub.uint = 0; uint32_t id_num = 0; - for (const auto& byte : span_bytes) { - memcpy(&sub.bytes[i++], &byte, sizeof(byte)); - id_num |= byte << (24 - (8*i)); - if (i == 3) - break; + uint8_t bytes_span[3] = { 0, 0, 0 }; + + // get 6 char from previous hash as varint + for (size_t i = 0; i < 3; i++) { + memcpy(&bytes_span[i], &b.prev_id.data[i], sizeof(b.prev_id.data[i])); + id_num |= bytes_span[i] << (24 - (8*(i+1))); } // guard against zero case