Multiple-comparison optimization suggestion #16597
Labels
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
dart2js-optimization
type-enhancement
A request for a change that isn't a bug
web-dart2js
[user feedback]
Dart2Js generates the following code for me:
removeEntity$1: [function(entity) {
var t1 = J.getInterceptor(entity);
if (typeof entity === "object" && entity !== null && !!t1.$isAmbientLightEntity)
C.JSArray_methods.remove$1(this._ambientLights, entity);
if (typeof entity === "object" && entity !== null && !!t1.$isDirectionalLightEntity)
C.JSArray_methods.remove$1(this._directionalLights, entity);
if (typeof entity === "object" && entity !== null && !!t1.$isPointLightEntity)
C.JSArray_methods.remove$1(this._pointLights, entity);
if (typeof entity === "object" && entity !== null && !!t1.$isSpotLightEntity)
C.JSArray_methods.remove$1(this._spotLights, entity);
E.RendererComponent.prototype.removeEntity$1.call(this, entity);
}, "call$1", "get$removeEntity", 2, 0, null, 676],
based on:
void removeEntity(Entity entity) {
if (entity is AmbientLightEntity) {
_ambientLights.remove(entity);
}
if (entity is DirectionalLightEntity) {
_directionalLights.remove(entity);
}
if (entity is PointLightEntity) {
_pointLights.remove(entity);
}
if (entity is SpotLightEntity) {
_spotLights.remove(entity);
}
super.removeEntity(entity);
}
Dart2Js should notice that it is checking the same thing multiple times (entity == null) and move it into an outer if statement.
////////////////////////////////////////////////////////////////////////////////////
Editor: 1.2.0.dev_02_04 (2014-01-31)
OS: Windows 8 - amd64 (6.2)
JVM: 1.7.0_21
projects: 1
open dart files: 0
auto-run pub: true
localhost resolves to: 127.0.0.1
mem max/total/free: 1778 / 784 / 113 MB
thread count: 29
index: 559247 relationships in 108843 keys in 15293 sources
SDK installed: true
Dartium installed: true
The text was updated successfully, but these errors were encountered: