HaxeFoundation / HaxeFoundation/hxcpp

Array<Entity> became as Array<::Dynamic>

Open
#589 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
330
Forks
227
Avg merge
2d 16h
Merged PRs (30d)
18

Description

`var entities:Array = new Array();`
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.
```
StaticCast (generated by Haxe): 3.10301402350888e-07
_hx_array_unsafe_get (using cpp.NativeArray): 0.0353070371420472
Removed StaticCast by hands: 0.0411155711772153
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the hxcpp code generation for `Array` and compare it with the generated `Array` and `StaticCast` shown in the issue. Use the reported element-access measurements as a baseline; done means generated arrays preserve the entity type without the unnecessary cast and the behavior is covered by an existing or newly located test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.