Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Improved dart.list and dart.map #571

Open

Description

@rakudrama

dart.list takes an element type. We should investigate using a factory constructor instead.

The problem is that

dart.list([1, 2, 3], core.int)

must to look up the type JSArray<core.int> each time.
We could generate a call to a factory constructor, e.g. named _of,

core.List$(core.int)._of([1, 2, 3])

This would still create the parameterized type, but we can then apply other improvements to the core.List$(core.int) part, e.g. precomputing it or caching it.

List<E>._of(array) could be defined in the patch file. It could simply call JSArray<E>.typed(array)
(we would want to fix #561 to make that faster).
Or List<E>._of could have a precomputed type JSArray<E> available to immediately store on the array.

Something similar could be done with dart.map to enable types to be evaluated less often.

Activity

  1. self-assigned this
    on May 20, 2016
  2. rakudrama commented on Jun 2, 2016

    @rakudrama
    ContributorAuthor

    List case has been implemented in b2ebb32

    dart.list([1, 2, 3], core.int)
    

    is now

    JSArrayOfint().of([1, 2, 3])
    

    where JSArrayOfint() is the cached evaluation of _interceptors.JSArray$(core.int)

    Map case is still TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions