Commit 2cd786b
committed
perf(linter/no-inner-declarations): remove unnecessary code and reduce branches (#11633)
1. Remove unnecessary check that grandparent of node is a `Function` or `ArrowFunctionExpression` when its parent is a `FunctionBody`. `FunctionBody` is always the child of `Function` or `ArrowFunctionExpression`, so this check is redundant.
2. If node is a `VariableStatement` or `Function`, it always has a parent node. So `unwrap` the parent instead of branching `if let Some(parent_node) = parent`. It's always `Some`.
The 2nd also allows skipping 1 turn of the loop further down because:
* If direct parent is a `StaticBlock`, we already exited.
* It's impossible for a variable or function declaration's parent to be a `Function` - there'd have to be a `FunctionBody` in between.1 parent 8776301 commit 2cd786b
File tree
1 file changed
+17
-24
lines changed- crates/oxc_linter/src/rules/eslint
1 file changed
+17
-24
lines changedLines changed: 17 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
109 | 95 | | |
110 | 96 | | |
111 | | - | |
112 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
113 | 105 | | |
114 | 106 | | |
115 | 107 | | |
| |||
119 | 111 | | |
120 | 112 | | |
121 | 113 | | |
| 114 | + | |
122 | 115 | | |
123 | 116 | | |
124 | 117 | | |
| |||
0 commit comments