Make the languages variable a constant containing string_view instances, and use shorter numbers in the LANGUAGE enum.

This commit is contained in:
Username404-59 2021-04-26 12:32:40 +02:00
parent 76e168fe58
commit 75fd1d93d4
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 3 additions and 3 deletions

View File

@ -2,15 +2,15 @@
using namespace std;
enum LANGUAGE: unsigned short {LUA=2,JS=3,PY=4};
enum LANGUAGE: unsigned short {LUA=0,JS=1,PY=2};
pair<LANGUAGE, bool> validLanguage(const string& it) {
const string languages[3] = {".lua", ".js", ".py"};
static const string_view languages[3] = {".lua", ".js", ".py"};
LANGUAGE selected = LUA;
bool valid = false;
for (unsigned short i = 0; (i < languages->size()); ++i) {
if (it == languages[i]) {
selected = static_cast<LANGUAGE>(i + 2);
selected = static_cast<LANGUAGE>(i);
valid = true;
break;
}