Skip to content

Commit

Permalink
Detect too many identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jun 12, 2024
1 parent 490b991 commit 36f59ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/swc_ecma_lints/src/rules/no_dupe_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ macro_rules! check {
// times.
let mut done = vec![];

let mut hash_mode = false;

let mut i1 = 0;
for_each_binding_ident($node, |id1| {
i1 += 1;
Expand All @@ -29,6 +31,15 @@ macro_rules! check {
for_each_binding_ident($node, |id2| {
i2 += 1;

if hash_mode {
return;
} else if i2 >= 100 {
// While iterating for the first `id1`, we detect that there are more than 100
// identifiers. We switch to hash mode.
hash_mode = true;
return;
}

if i1 >= i2 || done.contains(&i1) {
return;
}
Expand Down

0 comments on commit 36f59ba

Please sign in to comment.