Commit 23b6464
committed
feat(minifier): fold true / false comparison. (#6225)
Input:
```js
a == false
```
Previous:
```js
a == !1
```
Current:
```js
a == 0
```
Only handle it when it is non-plus, non-relation binary expressions. Align with [Closure Compiler](https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250Ax%2520%253C%253C%2520true%253B%250A%250Ax%2520%252B%2520true%253B%250A%250Ax%2520-%2520true%253B%250A%250Ax%2520%257C%2520true%253B%250A%250Ax%2520%2525%2520true%253B%250A%250Ay%2520!%253D%2520false%253B%250A%250Af()%2520%253D%253D%2520false%253B%250A%250Ax%2520instanceof%2520true%250A%250Ax%2520**%2520true%250A%250Ax%2520%2526%2520true%250A%250Ax%2520%255E%2520false%250A%250Ax%2520%253D%253D%2520(x%2520instanceof%2520false)%250A%250Ax%2520instanceof%2520(x%2520%253C%253C%2520true)%250A%250Ax%2520%253D%253D%2520fake(false)).1 parent acab777 commit 23b6464
File tree
2 files changed
+42
-18
lines changed- crates/oxc_minifier/src/ast_passes
- tasks/minsize
2 files changed
+42
-18
lines changedLines changed: 32 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
171 | 183 | | |
172 | 184 | | |
173 | | - | |
174 | | - | |
| 185 | + | |
| 186 | + | |
175 | 187 | | |
176 | 188 | | |
177 | | - | |
178 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
179 | 197 | | |
180 | | - | |
181 | 198 | | |
182 | 199 | | |
183 | 200 | | |
| |||
350 | 367 | | |
351 | 368 | | |
352 | 369 | | |
353 | | - | |
354 | 370 | | |
355 | 371 | | |
356 | 372 | | |
| |||
359 | 375 | | |
360 | 376 | | |
361 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
362 | 386 | | |
363 | 387 | | |
364 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
0 commit comments