Open posxposy opened 7 years ago
I'm not sure what these numbers are - the remove StaticCast is slower? The idea is that the static-cast should not actually generate any extra machine code in this case. The complexity is really only needed for getting elements from Arrays-of-Arrays, where the haxe typing system can't be trusted. I'm probably going to rewrite this soon, but any information would be good to take into account.
I meant, that StaticCast is much slower than direct access to array element.
As far as I know, the StaticCast should not change the machine code for all cases except where the element type itself is an array. Although, this would be worth verifying in the disassembly.
On Thu, Jun 8, 2017 at 5:29 PM, Dmitry Hryppa notifications@github.com wrote:
I meant, that StaticCast is much slower than direct access to array element.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HaxeFoundation/hxcpp/issues/589#issuecomment-307050457, or mute the thread https://github.com/notifications/unsubscribe-auth/ABlp1rRIvAV-PYUuzMwq3bjonmC3O4WDks5sB77_gaJpZM4M-McV .
var entities:Array<Entity> = new Array<Entity>();
where Entity is a regular Haxe class. This code is translated to:::Array< ::Dynamic> entities = ::Array_obj< ::Dynamic>::__new();
And to get access to any element of that array Haxe generated this code:
::lib::entities::Entity e = entities->__get(i1).StaticCast< ::lib::entities::Entity >();
Would be nice to avoid this StaticCast and generate arrays as
Array< ::Entity>
;I measured execution time for element access and here is what time I got.