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

length doesn't need an extension method #139

Closed
jmesserly opened this issue Apr 16, 2015 · 5 comments
Closed

length doesn't need an extension method #139

jmesserly opened this issue Apr 16, 2015 · 5 comments

Comments

@jmesserly
Copy link
Contributor

The JS impl is exactly same signature/result as Dart.

  int get length => JS('JSUInt32', r'#.length', this);

(source: JSArray in dart2js)

@jmesserly jmesserly added the js label Apr 16, 2015
@jmesserly
Copy link
Contributor Author

Funny, although now that I look, the setter is a bit different. Nevermind :)

@jmesserly
Copy link
Contributor Author

well, we could generate the reads as list.length though. Maybe still worth a special case?

fyi setter is:

  void set length(int newLength) {
    if (newLength is !int) throw new ArgumentError(newLength);
    if (newLength < 0) throw new RangeError.value(newLength);
    checkGrowable('set length');
    JS('void', r'#.length = #', this, newLength);
  }

The is! int checks and <0 checks probably we don't need, but the checkGrowable seems needed. That said, Arrays can be subclassed in ES6 so maybe we could implement non-growable that way.

@jmesserly jmesserly reopened this Apr 16, 2015
@jmesserly
Copy link
Contributor Author

related: #138

@jmesserly jmesserly self-assigned this May 29, 2015
@jmesserly jmesserly reopened this May 11, 2016
@jmesserly jmesserly removed their assignment May 11, 2016
@jmesserly
Copy link
Contributor Author

fyi @rakudrama just hit this. maybe we regressed .length special case at some point?

@jmesserly
Copy link
Contributor Author

going to close this out, if we hit again in perf investigations we can reopen

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

No branches or pull requests

1 participant