Relax cn algorithm constants definition.

This commit is contained in:
XMRig 2019-09-04 13:22:20 +07:00
parent 13daf095d9
commit e7b2b4fc3d
4 changed files with 66 additions and 155 deletions

View file

@ -24,27 +24,24 @@
*/
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "crypto/common/Algorithm.h"
#include "crypto/cn/CnAlgo.h"
#include "crypto/common/Algorithm.h"
#include "rapidjson/document.h"
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#ifdef _MSC_VER
# define strcasecmp _stricmp
#endif
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
namespace xmrig {
@ -274,9 +271,8 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
return ARGON2;
# endif
case INVALID:
case MAX:
return UNKNOWN;
default:
break;
}
return UNKNOWN;
@ -289,9 +285,9 @@ xmrig::Algorithm::Id xmrig::Algorithm::parse(const char *name)
return INVALID;
}
for (size_t i = 0; i < ARRAY_SIZE(algorithm_names); i++) {
if ((strcasecmp(name, algorithm_names[i].name) == 0) || (algorithm_names[i].shortName != nullptr && strcasecmp(name, algorithm_names[i].shortName) == 0)) {
return algorithm_names[i].id;
for (const AlgoName &item : algorithm_names) {
if ((strcasecmp(name, item.name) == 0) || (item.shortName != nullptr && strcasecmp(name, item.shortName) == 0)) {
return item.id;
}
}
@ -301,9 +297,9 @@ xmrig::Algorithm::Id xmrig::Algorithm::parse(const char *name)
const char *xmrig::Algorithm::name(bool shortName) const
{
for (size_t i = 0; i < ARRAY_SIZE(algorithm_names); i++) {
if (algorithm_names[i].id == m_id) {
return (shortName && algorithm_names[i].shortName) ? algorithm_names[i].shortName : algorithm_names[i].name;
for (const AlgoName &item : algorithm_names) {
if (item.id == m_id) {
return (shortName && item.shortName) ? item.shortName : item.name;
}
}