Avoid std::set in script version checks
This commit is contained in:
@@ -16,7 +16,8 @@
|
|||||||
#include "../string_func.h"
|
#include "../string_func.h"
|
||||||
#include "../rev.h"
|
#include "../rev.h"
|
||||||
#include "../core/format.hpp"
|
#include "../core/format.hpp"
|
||||||
#include <set>
|
#include <algorithm>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
@@ -26,8 +27,8 @@
|
|||||||
*/
|
*/
|
||||||
static bool CheckAPIVersion(const std::string &api_version)
|
static bool CheckAPIVersion(const std::string &api_version)
|
||||||
{
|
{
|
||||||
static const std::set<std::string> versions = { "0.7", "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "12", "13", "14" };
|
static constexpr std::initializer_list<const char*> versions{ "0.7", "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "12", "13", "14" };
|
||||||
return versions.find(api_version) != versions.end();
|
return std::find_if(versions.begin(), versions.end(), [&](const char *v) { return api_version == v; }) != versions.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@@ -13,7 +13,8 @@
|
|||||||
#include "game_info.hpp"
|
#include "game_info.hpp"
|
||||||
#include "game_scanner.hpp"
|
#include "game_scanner.hpp"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
#include <set>
|
#include <algorithm>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
@@ -23,8 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
static bool CheckAPIVersion(const std::string &api_version)
|
static bool CheckAPIVersion(const std::string &api_version)
|
||||||
{
|
{
|
||||||
static const std::set<std::string> versions = { "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "12", "13", "14" };
|
static constexpr std::initializer_list<const char*> versions{ "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "12", "13", "14" };
|
||||||
return versions.find(api_version) != versions.end();
|
return std::find_if(versions.begin(), versions.end(), [&](const char *v) { return api_version == v; }) != versions.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
Reference in New Issue
Block a user