Make the languages variable a constant containing string_view instances, and use shorter numbers in the LANGUAGE enum.
This commit is contained in:
parent
76e168fe58
commit
75fd1d93d4
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue