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.

Faster JSArray.typed #561

Closed
Closed

Description

@rakudrama

JSArray.sublist uses Array.slice and tags the result.

    _interceptors.JSArray$ = dart.generic(E => {
    ...
    class JSArray extends core.Object {
      JSArray() {
      }
      static typed(allocation) {
        return dart.list(allocation, E);  // [B]
      }
      ...
      [dartx.sublist](start, end) {
        ...
        return _interceptors.JSArray$(E).typed(this.slice(start, end));   // [A]
      }

We can make [A] faster by recognizing that _interceptors.JSArray$(E) has a faster alias, JSArray.

We also need to make [B] faster. It also does a lookup of the parameterized type.

  dart.list = function(obj, elementType) {
    return dart.setType(obj, dart.getGenericClass(_interceptors.JSArray)(elementType));
  };

It seems that we should be able to change typed to also use the faster alias:

      static typed(allocation) {
        return dart.setType(allocation, JSArray);  // [B]
      }

Doing this by hand seems to speed lib/convert/ascii_test by ~5%

Activity

  1. rakudrama commented on Jun 2, 2016

    @rakudrama
    ContributorAuthor

    Fixed in b2ebb32

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions