提交 39dea0ff 编写于 作者: B Benjamin Pasero

allow V8 to optimize globToRegExp

上级 ccf9a301
......@@ -231,12 +231,7 @@ function globToRegExp(pattern: string): RegExp {
regEx = '^' + regEx + '$';
// Convert to regexp and be ready for errors
let result: RegExp;
try {
result = new RegExp(regEx);
} catch (error) {
result = /.^/; // create a regex that matches nothing if we cannot parse the pattern
}
let result = toRegExp(regEx);
// Make sure to cache
CACHE[pattern] = result;
......@@ -244,6 +239,14 @@ function globToRegExp(pattern: string): RegExp {
return result;
}
function toRegExp(regEx: string): RegExp {
try {
return new RegExp(regEx);
} catch (error) {
return /.^/; // create a regex that matches nothing if we cannot parse the pattern
}
}
/**
* Simplified glob matching. Supports a subset of glob patterns:
* - * matches anything inside a path segment
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册