| Index: lib/runtime/dart/collection.js
|
| diff --git a/lib/runtime/dart/collection.js b/lib/runtime/dart/collection.js
|
| index 9936fce10d9a5a35f63d6e04a4cfc034df52a457..d250c522cfefad90a3ffc84c72c17e7d3bd52d88 100644
|
| --- a/lib/runtime/dart/collection.js
|
| +++ b/lib/runtime/dart/collection.js
|
| @@ -150,10 +150,9 @@ var collection;
|
| return true;
|
| }
|
| union(other) {
|
| - return ((_) => {
|
| - _.addAll(other);
|
| - return _;
|
| - })(this.toSet());
|
| + let _ = this.toSet();
|
| + _.addAll(other);
|
| + return _;
|
| }
|
| intersection(other) {
|
| let result = this.toSet();
|
| @@ -173,13 +172,10 @@ var collection;
|
| }
|
| [core.$toList](opts) {
|
| let growable = opts && 'growable' in opts ? opts.growable : true;
|
| - let result = growable ? ((_) => {
|
| - _[core.$length] = this.length;
|
| - return _;
|
| - }).bind(this)(new (core.List$(E))()) : new (core.List$(E))(this.length);
|
| + let result = growable ? ((_) => (_ = new (core.List$(E))(), _[core.$length] = this.length, _)).bind(this)() : new (core.List$(E))(this.length);
|
| let i = 0;
|
| for (let element of this)
|
| - result[core.$set](((x$) => i = dart.notNull(x$) + 1, x$)(i), element);
|
| + result[core.$set](((x$) => (x$ = i, i = dart.notNull(x$) + 1, x$))(), element);
|
| return result;
|
| }
|
| [core.$map](f) {
|
| @@ -375,10 +371,7 @@ var collection;
|
| return result;
|
| }
|
| [core.$toSet]() {
|
| - return ((_) => {
|
| - _.addAll(this);
|
| - return _;
|
| - }).bind(this)(this[_newSet]());
|
| + return ((_) => (_ = this[_newSet](), _.addAll(this), _)).bind(this)();
|
| }
|
| }
|
| return _HashSetBase;
|
| @@ -842,10 +835,11 @@ var collection;
|
| IterableBase[_toStringVisiting][core.$removeLast]();
|
| }
|
| return ((_) => {
|
| + _ = new core.StringBuffer(leftDelimiter);
|
| _.writeAll(parts, ", ");
|
| _.write(rightDelimiter);
|
| return _;
|
| - })(new core.StringBuffer(leftDelimiter)).toString();
|
| + })().toString();
|
| }
|
| static iterableToFullString(iterable, leftDelimiter, rightDelimiter) {
|
| if (leftDelimiter === void 0)
|
| @@ -888,7 +882,7 @@ var collection;
|
| return;
|
| let next = `${it.current}`;
|
| parts[core.$add](next);
|
| - length = dart.notNull(next.length) + dart.notNull(OVERHEAD);
|
| + length = dart.notNull(length) + (dart.notNull(next.length) + dart.notNull(OVERHEAD));
|
| count = dart.notNull(count) + 1;
|
| }
|
| let penultimateString = null;
|
| @@ -910,7 +904,7 @@ var collection;
|
| }
|
| ultimateString = `${penultimate}`;
|
| penultimateString = dart.as(parts[core.$removeLast](), core.String);
|
| - length = dart.notNull(ultimateString.length) + dart.notNull(OVERHEAD);
|
| + length = dart.notNull(length) + (dart.notNull(ultimateString.length) + dart.notNull(OVERHEAD));
|
| } else {
|
| ultimate = it.current;
|
| count = dart.notNull(count) + 1;
|
| @@ -921,7 +915,7 @@ var collection;
|
| count = dart.notNull(count) + 1;
|
| if (dart.notNull(count) > dart.notNull(MAX_COUNT)) {
|
| while (dart.notNull(length) > dart.notNull(LENGTH_LIMIT) - dart.notNull(ELLIPSIS_SIZE) - dart.notNull(OVERHEAD) && dart.notNull(count) > dart.notNull(HEAD_COUNT)) {
|
| - length = dart.as(dart.dbinary(dart.dload(parts[core.$removeLast](), 'length'), '+', OVERHEAD), core.int);
|
| + length = dart.notNull(length) - dart.notNull(dart.as(dart.dbinary(dart.dload(parts[core.$removeLast](), 'length'), '+', OVERHEAD), core.int));
|
| count = dart.notNull(count) - 1;
|
| }
|
| parts[core.$add]("...");
|
| @@ -930,19 +924,19 @@ var collection;
|
| }
|
| penultimateString = `${penultimate}`;
|
| ultimateString = `${ultimate}`;
|
| - length = dart.notNull(ultimateString.length) + dart.notNull(penultimateString.length) + 2 * dart.notNull(OVERHEAD);
|
| + length = dart.notNull(length) + (dart.notNull(ultimateString.length) + dart.notNull(penultimateString.length) + 2 * dart.notNull(OVERHEAD));
|
| }
|
| }
|
| let elision = null;
|
| if (dart.notNull(count) > dart.notNull(parts[core.$length]) + dart.notNull(TAIL_COUNT)) {
|
| elision = "...";
|
| - length = dart.notNull(ELLIPSIS_SIZE) + dart.notNull(OVERHEAD);
|
| + length = dart.notNull(length) + (dart.notNull(ELLIPSIS_SIZE) + dart.notNull(OVERHEAD));
|
| }
|
| while (dart.notNull(length) > dart.notNull(LENGTH_LIMIT) && dart.notNull(parts[core.$length]) > dart.notNull(HEAD_COUNT)) {
|
| - length = dart.as(dart.dbinary(dart.dload(parts[core.$removeLast](), 'length'), '+', OVERHEAD), core.int);
|
| + length = dart.notNull(length) - dart.notNull(dart.as(dart.dbinary(dart.dload(parts[core.$removeLast](), 'length'), '+', OVERHEAD), core.int));
|
| if (elision == null) {
|
| elision = "...";
|
| - length = dart.notNull(ELLIPSIS_SIZE) + dart.notNull(OVERHEAD);
|
| + length = dart.notNull(length) + (dart.notNull(ELLIPSIS_SIZE) + dart.notNull(OVERHEAD));
|
| }
|
| }
|
| if (elision != null) {
|
| @@ -1481,10 +1475,8 @@ var collection;
|
| let growable = opts && 'growable' in opts ? opts.growable : true;
|
| let result = null;
|
| if (growable) {
|
| - result = ((_) => {
|
| - _[core.$length] = this.length;
|
| - return _;
|
| - }).bind(this)(new (core.List$(E))());
|
| + result = new (core.List$(E))();
|
| + result[core.$length] = this.length;
|
| } else {
|
| result = new (core.List$(E))(this.length);
|
| }
|
| @@ -1501,18 +1493,29 @@ var collection;
|
| return result;
|
| }
|
| [core.$add](element) {
|
| - this[core.$set](((x$) => this[core.$length] = dart.notNull(x$) + 1, x$).bind(this)(this[core.$length]), element);
|
| + this[core.$set](((o$, x$) => {
|
| + o$ = this;
|
| + x$ = o$[core.$length];
|
| + o$[core.$length] = dart.notNull(x$) + 1;
|
| + return x$;
|
| + }).bind(this)(), element);
|
| }
|
| [core.$addAll](iterable) {
|
| for (let element of iterable) {
|
| - this[core.$set](((x$) => this[core.$length] = dart.notNull(x$) + 1, x$).bind(this)(this[core.$length]), element);
|
| + this[core.$set](((o$, x$) => {
|
| + o$ = this;
|
| + x$ = o$[core.$length];
|
| + o$[core.$length] = dart.notNull(x$) + 1;
|
| + return x$;
|
| + }).bind(this)(), element);
|
| }
|
| }
|
| [core.$remove](element) {
|
| for (let i = 0; dart.notNull(i) < dart.notNull(this[core.$length]); i = dart.notNull(i) + 1) {
|
| if (dart.equals(this[core.$get](i), element)) {
|
| this[core.$setRange](i, dart.notNull(this[core.$length]) - 1, this, dart.notNull(i) + 1);
|
| - this[core.$length] = 1;
|
| + let o$ = this;
|
| + o$[core.$length] = dart.notNull(o$[core.$length]) - 1;
|
| return true;
|
| }
|
| }
|
| @@ -1569,7 +1572,7 @@ var collection;
|
| let length = this[core.$length];
|
| while (dart.notNull(length) > 1) {
|
| let pos = random.nextInt(length);
|
| - length = 1;
|
| + length = dart.notNull(length) - 1;
|
| let tmp = this[core.$get](length);
|
| this[core.$set](length, this[core.$get](pos));
|
| this[core.$set](pos, tmp);
|
| @@ -1601,7 +1604,8 @@ var collection;
|
| core.RangeError.checkValidRange(start, end, this[core.$length]);
|
| let length = dart.notNull(end) - dart.notNull(start);
|
| this.setRange(start, dart.notNull(this[core.$length]) - dart.notNull(length), this, end);
|
| - this[core.$length] = length;
|
| + let o$ = this;
|
| + o$[core.$length] = dart.notNull(o$[core.$length]) - dart.notNull(length);
|
| }
|
| [core.$fillRange](start, end, fill) {
|
| if (fill === void 0)
|
| @@ -1710,7 +1714,8 @@ var collection;
|
| }
|
| if (!(typeof index == 'number'))
|
| throw new core.ArgumentError(index);
|
| - this[core.$length] = dart.notNull(this[core.$length]) + 1;
|
| + let o$ = this;
|
| + o$[core.$length] = dart.notNull(o$[core.$length]) + 1;
|
| this.setRange(dart.notNull(index) + 1, this[core.$length], this, index);
|
| this[core.$set](index, element);
|
| }
|
| @@ -1726,7 +1731,8 @@ var collection;
|
| iterable = iterable[core.$toList]();
|
| }
|
| let insertionLength = iterable[core.$length];
|
| - this[core.$length] = insertionLength;
|
| + let o$ = this;
|
| + o$[core.$length] = dart.notNull(o$[core.$length]) + dart.notNull(insertionLength);
|
| this.setRange(dart.notNull(index) + dart.notNull(insertionLength), this[core.$length], this, index);
|
| this.setAll(index, iterable);
|
| }
|
| @@ -1735,7 +1741,7 @@ var collection;
|
| this.setRange(index, dart.notNull(index) + dart.notNull(iterable[core.$length]), iterable);
|
| } else {
|
| for (let element of iterable) {
|
| - this[core.$set](((x$) => index = dart.notNull(x$) + 1, x$)(index), element);
|
| + this[core.$set](((x$) => (x$ = index, index = dart.notNull(x$) + 1, x$))(), element);
|
| }
|
| }
|
| }
|
| @@ -2382,10 +2388,8 @@ var collection;
|
| let growable = opts && 'growable' in opts ? opts.growable : true;
|
| let list = null;
|
| if (growable) {
|
| - list = ((_) => {
|
| - _[core.$length] = this.length;
|
| - return _;
|
| - }).bind(this)(new (core.List$(E))());
|
| + list = new (core.List$(E))();
|
| + list[core.$length] = this.length;
|
| } else {
|
| list = new (core.List$(E))(this.length);
|
| }
|
| @@ -2403,12 +2407,12 @@ var collection;
|
| if (dart.notNull(length) + dart.notNull(addCount) >= dart.notNull(this[_table][core.$length])) {
|
| this[_preGrow](dart.notNull(length) + dart.notNull(addCount));
|
| this[_table][core.$setRange](length, dart.notNull(length) + dart.notNull(addCount), dart.as(list, core.Iterable$(E)), 0);
|
| - this[_tail] = addCount;
|
| + this[_tail] = dart.notNull(this[_tail]) + dart.notNull(addCount);
|
| } else {
|
| let endSpace = dart.notNull(this[_table][core.$length]) - dart.notNull(this[_tail]);
|
| if (dart.notNull(addCount) < dart.notNull(endSpace)) {
|
| this[_table][core.$setRange](this[_tail], dart.notNull(this[_tail]) + dart.notNull(addCount), dart.as(list, core.Iterable$(E)), 0);
|
| - this[_tail] = addCount;
|
| + this[_tail] = dart.notNull(this[_tail]) + dart.notNull(addCount);
|
| } else {
|
| let preSpace = dart.notNull(addCount) - dart.notNull(endSpace);
|
| this[_table][core.$setRange](this[_tail], dart.notNull(this[_tail]) + dart.notNull(endSpace), dart.as(list, core.Iterable$(E)), 0);
|
| @@ -2570,7 +2574,7 @@ var collection;
|
| }
|
| [_preGrow](newElementCount) {
|
| dart.assert(dart.notNull(newElementCount) >= dart.notNull(this.length));
|
| - newElementCount = dart.notNull(newElementCount) >> 1;
|
| + newElementCount = dart.notNull(newElementCount) + (dart.notNull(newElementCount) >> 1);
|
| let newCapacity = ListQueue[_nextPowerOf2](newElementCount);
|
| let newTable = new (core.List$(E))(newCapacity);
|
| this[_tail] = this[_writeToList](newTable);
|
| @@ -3299,10 +3303,9 @@ var collection;
|
| return result;
|
| }
|
| union(other) {
|
| - return ((_) => {
|
| - _.addAll(other);
|
| - return _;
|
| - })(this[_clone]());
|
| + let _ = this[_clone]();
|
| + _.addAll(other);
|
| + return _;
|
| }
|
| [_clone]() {
|
| let set = new (SplayTreeSet$(E))(dart.as(this[_comparator], dart.throw_("Unimplemented type (E, E) → int")), this[_validKey]);
|
| @@ -3313,11 +3316,10 @@ var collection;
|
| [_copyNode](node) {
|
| if (node == null)
|
| return null;
|
| - return ((_) => {
|
| - _.left = this[_copyNode](node.left);
|
| - _.right = this[_copyNode](node.right);
|
| - return _;
|
| - }).bind(this)(new (_SplayTreeNode$(E))(node.key));
|
| + let _ = new (_SplayTreeNode$(E))(node.key);
|
| + _.left = this[_copyNode](node.left);
|
| + _.right = this[_copyNode](node.right);
|
| + return _;
|
| }
|
| clear() {
|
| this[_clear]();
|
| @@ -3534,7 +3536,7 @@ var collection;
|
| let key = names[i];
|
| let bucket = rest[key];
|
| let length = bucket.length;
|
| - for (let i = 0; dart.notNull(i) < dart.notNull(length); i = 2) {
|
| + for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 2) {
|
| let key = bucket[i];
|
| result[index] = key;
|
| index = dart.notNull(index) + 1;
|
| @@ -3597,7 +3599,7 @@ var collection;
|
| if (bucket == null)
|
| return -1;
|
| let length = bucket.length;
|
| - for (let i = 0; dart.notNull(i) < dart.notNull(length); i = 2) {
|
| + for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 2) {
|
| if (dart.equals(bucket[i], key))
|
| return i;
|
| }
|
| @@ -3624,7 +3626,7 @@ var collection;
|
| if (bucket == null)
|
| return -1;
|
| let length = bucket.length;
|
| - for (let i = 0; dart.notNull(i) < dart.notNull(length); i = 2) {
|
| + for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 2) {
|
| if (core.identical(bucket[i], key))
|
| return i;
|
| }
|
| @@ -3669,7 +3671,7 @@ var collection;
|
| if (bucket == null)
|
| return -1;
|
| let length = bucket.length;
|
| - for (let i = 0; dart.notNull(i) < dart.notNull(length); i = 2) {
|
| + for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 2) {
|
| if (this[_equals](dart.as(bucket[i], K), dart.as(key, K)))
|
| return i;
|
| }
|
|
|