Skip to content

Commit efb502a

Browse files
committed
Remove unnecessary boolean casts
1 parent 3b947da commit efb502a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/compiler/iroptimizer.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ class IROptimizer {
158158
case InputOpcode.ADDON_CALL:
159159
break;
160160

161+
case InputOpcode.CAST_BOOLEAN: {
162+
const innerType = inputs.target.type;
163+
if (innerType & InputType.BOOLEAN) return innerType;
164+
return InputType.BOOLEAN;
165+
}
166+
161167
case InputOpcode.CAST_NUMBER: {
162168
const innerType = inputs.target.type;
163169
if (innerType & InputType.NUMBER) return innerType;
@@ -707,6 +713,14 @@ class IROptimizer {
707713
}
708714

709715
switch (input.opcode) {
716+
case InputOpcode.CAST_BOOLEAN: {
717+
const targetType = input.inputs.target.type;
718+
if ((targetType & InputType.BOOLEAN) === targetType) {
719+
return input.inputs.target;
720+
}
721+
return input;
722+
}
723+
710724
case InputOpcode.CAST_NUMBER: {
711725
const targetType = input.inputs.target.type;
712726
if ((targetType & InputType.NUMBER) === targetType) {

0 commit comments

Comments
 (0)