提交 d5592d58 编写于 作者: B Benjamin Pasero

optimize glob.match call

- do not use try/catch in function body as it prevents method optimization in V8
- skip over disabled expressions
上级 afbca7b2
......@@ -261,11 +261,8 @@ export function match(arg1: string|IExpression, path: string, siblings?: string[
// Glob with String
if (typeof arg1 === 'string') {
try {
return globToRegExp(arg1).test(path);
} catch (error) {
return false; // ignore pattern if the regex is invalid
}
var regExp = globToRegExp(arg1);
return regExp && regExp.test(path);
}
// Glob with Expression
......@@ -277,16 +274,16 @@ function matchExpression(expression: IExpression, path: string, siblings?: strin
for (let i = 0; i < patterns.length; i++) {
let pattern = patterns[i];
let value = expression[pattern];
if (value === false) {
continue; // pattern is disabled
}
// Pattern matches path
if (match(pattern, path)) {
let value = expression[pattern];
// Expression Pattern is <boolean>
if (typeof value === 'boolean') {
if (value === false) {
continue; // pattern is disabled
}
return pattern;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册