Caching added for Magic regexes

This commit is contained in:
n1073645 2020-03-12 14:45:40 +00:00
parent 570a84b67a
commit 5b5105c864

View File

@ -36,10 +36,10 @@ class Magic {
const matches = [];
for (let i = 0; i < opPatterns.length; i++) {
const pattern = opPatterns[i],
regex = new RegExp(pattern.match, pattern.flags);
const pattern = opPatterns[i];
if (regex.test(this.inputStr)) {
if (pattern.match.test(this.inputStr)) {
matches.push(pattern);
}
}
@ -522,8 +522,7 @@ class Magic {
OperationConfig[op].input.regex.forEach(pattern => {
opCriteria.regex.push({
op: op,
match: pattern.match,
flags: pattern.flags,
match: new RegExp(pattern.match, pattern.flags),
args: pattern.args,
useful: pattern.useful || false
});