diff --git a/src/crypto/cn/CnHash.cpp b/src/crypto/cn/CnHash.cpp index d085bf63a..a1bec4967 100644 --- a/src/crypto/cn/CnHash.cpp +++ b/src/crypto/cn/CnHash.cpp @@ -40,34 +40,30 @@ #endif -#define ADD_FN(algo) do { \ - cn_hash_fun_array* arr = new cn_hash_fun_array{}; \ - auto& data = arr->data; \ - data[AV_SINGLE][Assembly::NONE] = cryptonight_single_hash; \ - data[AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash; \ - data[AV_DOUBLE][Assembly::NONE] = cryptonight_double_hash; \ - data[AV_DOUBLE_SOFT][Assembly::NONE] = cryptonight_double_hash; \ - data[AV_TRIPLE][Assembly::NONE] = cryptonight_triple_hash; \ - data[AV_TRIPLE_SOFT][Assembly::NONE] = cryptonight_triple_hash; \ - data[AV_QUAD][Assembly::NONE] = cryptonight_quad_hash; \ - data[AV_QUAD_SOFT][Assembly::NONE] = cryptonight_quad_hash; \ - data[AV_PENTA][Assembly::NONE] = cryptonight_penta_hash; \ - data[AV_PENTA_SOFT][Assembly::NONE] = cryptonight_penta_hash; \ - m_map.insert(std::make_pair(algo, arr)); \ +#define ADD_FN(algo) do { \ + if (!m_map[algo]) m_map[algo] = new cn_hash_fun_array{}; \ + m_map[algo]->data[AV_SINGLE][Assembly::NONE] = cryptonight_single_hash; \ + m_map[algo]->data[AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash; \ + m_map[algo]->data[AV_DOUBLE][Assembly::NONE] = cryptonight_double_hash; \ + m_map[algo]->data[AV_DOUBLE_SOFT][Assembly::NONE] = cryptonight_double_hash; \ + m_map[algo]->data[AV_TRIPLE][Assembly::NONE] = cryptonight_triple_hash; \ + m_map[algo]->data[AV_TRIPLE_SOFT][Assembly::NONE] = cryptonight_triple_hash; \ + m_map[algo]->data[AV_QUAD][Assembly::NONE] = cryptonight_quad_hash; \ + m_map[algo]->data[AV_QUAD_SOFT][Assembly::NONE] = cryptonight_quad_hash; \ + m_map[algo]->data[AV_PENTA][Assembly::NONE] = cryptonight_penta_hash; \ + m_map[algo]->data[AV_PENTA_SOFT][Assembly::NONE] = cryptonight_penta_hash; \ } while (0) #ifdef XMRIG_FEATURE_ASM -# define ADD_FN_ASM(algo) do { \ - cn_hash_fun_array* arr = new cn_hash_fun_array{}; \ - auto& data = arr->data; \ - data[AV_SINGLE][Assembly::INTEL] = cryptonight_single_hash_asm; \ - data[AV_SINGLE][Assembly::RYZEN] = cryptonight_single_hash_asm; \ - data[AV_SINGLE][Assembly::BULLDOZER] = cryptonight_single_hash_asm; \ - data[AV_DOUBLE][Assembly::INTEL] = cryptonight_double_hash_asm; \ - data[AV_DOUBLE][Assembly::RYZEN] = cryptonight_double_hash_asm; \ - data[AV_DOUBLE][Assembly::BULLDOZER] = cryptonight_double_hash_asm; \ - m_map.insert(std::make_pair(algo, arr)); \ +# define ADD_FN_ASM(algo) do { \ + if (!m_map[algo]) m_map[algo] = new cn_hash_fun_array{}; \ + m_map[algo]->data[AV_SINGLE][Assembly::INTEL] = cryptonight_single_hash_asm; \ + m_map[algo]->data[AV_SINGLE][Assembly::RYZEN] = cryptonight_single_hash_asm; \ + m_map[algo]->data[AV_SINGLE][Assembly::BULLDOZER] = cryptonight_single_hash_asm; \ + m_map[algo]->data[AV_DOUBLE][Assembly::INTEL] = cryptonight_double_hash_asm; \ + m_map[algo]->data[AV_DOUBLE][Assembly::RYZEN] = cryptonight_double_hash_asm; \ + m_map[algo]->data[AV_DOUBLE][Assembly::BULLDOZER] = cryptonight_double_hash_asm; \ } while (0)