Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization: skip one unnecessary checking in the loop #16438

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/babel-types/src/validators/matchesPattern.ts
Expand Up @@ -22,13 +22,13 @@
if (!isMemberExpression(member)) return false;

const parts = Array.isArray(match) ? match : match.split(".");
const nodes = [];
const nodes = [member.property];

let node;
for (node = member; isMemberExpression(node); node = node.object) {
let node: t.Node = member.object;
for (; isMemberExpression(node); node = node.object) {
nodes.push(node.property);
}
nodes.push(node);

Check failure on line 31 in packages/babel-types/src/validators/matchesPattern.ts

View workflow job for this annotation

GitHub Actions / Publish to local Verdaccio registry

Argument of type 'ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | ... 46 more ... | YieldExpression' is not assignable to parameter of type 'PrivateName | Expression'.

Check failure on line 31 in packages/babel-types/src/validators/matchesPattern.ts

View workflow job for this annotation

GitHub Actions / Build Babel 8 Artifacts

Argument of type 'ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | ... 46 more ... | YieldExpression' is not assignable to parameter of type 'PrivateName | Expression'.

if (nodes.length < parts.length) return false;
if (!allowPartial && nodes.length > parts.length) return false;
Expand Down