Remove unnecessary string casts
This commit is contained in:
1 parent
36d4d8224b
commit
67cb7cfc5d
4 files changed
+26
-8
No files matched your search
@@ -162,12 +162,20 @@ class IROptimizer {
|
||||
const innerType = inputs.target.type;
|
||||
if (innerType & InputType.NUMBER) return innerType;
|
||||
return InputType.NUMBER;
|
||||
} case InputOpcode.CAST_NUMBER_OR_NAN: {
|
||||
}
|
||||
|
||||
case InputOpcode.CAST_NUMBER_OR_NAN: {
|
||||
const innerType = inputs.target.type;
|
||||
if (innerType & InputType.NUMBER_OR_NAN) return innerType;
|
||||
return InputType.NUMBER_OR_NAN;
|
||||
}
|
||||
|
||||
case InputOpcode.CAST_STRING: {
|
||||
const innerType = inputs.target.type;
|
||||
if (innerType & InputType.STRING) return innerType;
|
||||
return InputType.STRING;
|
||||
}
|
||||
|
||||
case InputOpcode.OP_ADD: {
|
||||
const leftType = inputs.left.type;
|
||||
const rightType = inputs.right.type;
|
||||
@@ -699,13 +707,23 @@ class IROptimizer {
|
||||
return input.inputs.target;
|
||||
}
|
||||
return input;
|
||||
} case InputOpcode.CAST_NUMBER_OR_NAN: {
|
||||
}
|
||||
|
||||
case InputOpcode.CAST_NUMBER_OR_NAN: {
|
||||
const targetType = input.inputs.target.type;
|
||||
if ((targetType & InputType.NUMBER_OR_NAN) === targetType) {
|
||||
return input.inputs.target;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
case InputOpcode.CAST_STRING: {
|
||||
const targetType = input.inputs.target.type;
|
||||
if ((targetType & InputType.STRING) === targetType) {
|
||||
return input.inputs.target;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
|
||||
@@ -52,7 +52,7 @@ if (compareEqual((b4 ? b4.value : 0), 0)) {
|
||||
yield* executeInCompatibilityLayer({"MESSAGE":"pass non existent variable",}, b0, false, false, ")nnN?*l+E)dC(fT5(_@q", null);
|
||||
}
|
||||
b5.value = (("" + randomInt(1, 9)) + ("" + randomInt(1, 9)));
|
||||
if (compareEqual(runtime.ext_scratch3_sensing.getAttributeOf({OBJECT: ("" + b5.value), PROPERTY: "backdrop #" }), 0)) {
|
||||
if (compareEqual(runtime.ext_scratch3_sensing.getAttributeOf({OBJECT: b5.value, PROPERTY: "backdrop #" }), 0)) {
|
||||
yield* executeInCompatibilityLayer({"MESSAGE":"pass NE backdrop #",}, b0, false, false, "UFr{fbR3@a.u_paq:r]F", null);
|
||||
}
|
||||
if (compareEqual(runtime.ext_scratch3_sensing.getAttributeOf({OBJECT: ("" + b5.value), PROPERTY: "backdrop name" }), 0)) {
|
||||
|
||||
@@ -24,11 +24,11 @@ return function funXYZ_a () {
|
||||
b0.value = "ababa";
|
||||
b1.value = "";
|
||||
b2.value = 1;
|
||||
for (var a0 = ("" + b0.value).length; a0 > 0; a0--) {
|
||||
if ((((("" + b0.value))[(b2.value | 0) - 1] || "").toLowerCase() === "a".toLowerCase())) {
|
||||
b1.value = (("" + b1.value) + "b");
|
||||
for (var a0 = b0.value.length; a0 > 0; a0--) {
|
||||
if ((((b0.value)[(b2.value | 0) - 1] || "").toLowerCase() === "a".toLowerCase())) {
|
||||
b1.value = (b1.value + "b");
|
||||
} else {
|
||||
b1.value = (("" + b1.value) + "a");
|
||||
b1.value = (b1.value + "a");
|
||||
}
|
||||
b2.value = (b2.value + 1);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ if (compareEqual((b4 ? b4.value : 0), 0)) {
|
||||
yield* executeInCompatibilityLayer({"MESSAGE":"pass non existent variable",}, b0, false, false, ")nnN?*l+E)dC(fT5(_@q", null);
|
||||
}
|
||||
b5.value = (("" + randomInt(1, 9)) + ("" + randomInt(1, 9)));
|
||||
if (compareEqual(runtime.ext_scratch3_sensing.getAttributeOf({OBJECT: ("" + b5.value), PROPERTY: "backdrop #" }), 0)) {
|
||||
if (compareEqual(runtime.ext_scratch3_sensing.getAttributeOf({OBJECT: b5.value, PROPERTY: "backdrop #" }), 0)) {
|
||||
yield* executeInCompatibilityLayer({"MESSAGE":"pass NE backdrop #",}, b0, false, false, "UFr{fbR3@a.u_paq:r]F", null);
|
||||
}
|
||||
if (compareEqual(runtime.ext_scratch3_sensing.getAttributeOf({OBJECT: ("" + b5.value), PROPERTY: "backdrop name" }), 0)) {
|
||||
|
||||
Reference in new issue
Block a user