public function add<T>(component:T, componentClass:Class<Dynamic> = null):Entity
{
if (componentClass == null)
componentClass = #if flash untyped component.constructor; #else Type.getClass(component); #end
if (components.exists(componentClass))
remove(componentClass);
components.set(componentClass, component);
componentAdded.dispatch(this, componentClass);
return this;
}
Flash AS3 target can use Object(unknown).constructor to quickly get class property. Actually, i think JS also might have something similar. Just a better optimization since the proxy method Type.getClass may have overhead since they aren't inlined with static method call extern.
Of course, it's also possible to switch Haxe and AS3 codebases interchangably (ie. use AS3's version of Ash over the Haxe codebase), since the API methods are the same. In this way, i code some systems in Haxe taking some advantage of inlining, but still run native AS3 Ash codebase over the compiled haxe SWC to optimize for native AS3 flash environment. However, i do somewhat prefer the Haxe macro generation benefits, which would be lost with the native AS3 codebase. So, there are pros and cons to both.
Flash AS3 target can use Object(unknown).constructor to quickly get class property. Actually, i think JS also might have something similar. Just a better optimization since the proxy method Type.getClass may have overhead since they aren't inlined with static method call extern.
Of course, it's also possible to switch Haxe and AS3 codebases interchangably (ie. use AS3's version of Ash over the Haxe codebase), since the API methods are the same. In this way, i code some systems in Haxe taking some advantage of inlining, but still run native AS3 Ash codebase over the compiled haxe SWC to optimize for native AS3 flash environment. However, i do somewhat prefer the Haxe macro generation benefits, which would be lost with the native AS3 codebase. So, there are pros and cons to both.