refactor(forEach): change to for-of with iterable#919
Conversation
|
@gdi2290 the Travis error comes from the benchmarks. infinite_scroll uses |
|
@vicb thanks I couldn't make out what the Travis error was. Give me a second |
|
@vicb Dart doesn't have a for-of so how do we change the directive interface for Dart users to use for-in. |
|
:/ I'm doing something wrong with my Dart version void iterateListLike(iter, fn(item)) {
if (iter is List) {
for (var item = 0; item < iter.length; ++item) {
fn(iter[item]);
}
} else {
for (var item in iter) {
fn(item);
}
}
}update: I found one error for iterable_changes in Dart. check(collection):boolean {
this._reset();
var record:CollectionChangeRecord = this._itHead;
var mayBeDirty:boolean = false;
var index:int, item;
if (ListWrapper.isList(collection)) {
var list = collection;
this._length = collection.length;
for (index = 0; index < this._length; index++) {
item = list[index];
if (record === null || !looseIdentical(record.item, item)) {
record = this._mismatch(record, item, index);
mayBeDirty = true;
} else if (mayBeDirty) {
// TODO(misko): can we limit this to duplicates only?
record = this._verifyReinsertion(record, item, index);
}
record = record._next;
}
} else {
index = 0;
iterateListLike(collection, (item) => {
if (record === null || !looseIdentical(record.item, item)) {
record = this._mismatch(record, item, index);
mayBeDirty = true;
} else if (mayBeDirty) {
// TODO(misko): can we limit this to duplicates only?
record = this._verifyReinsertion(record, item, index);
}
record = record._next;
index++
});
this._length = index;
}after refactor check(collection):boolean {
this._reset();
var record:CollectionChangeRecord = this._itHead;
var mayBeDirty:boolean = false;
var index:int, item;
index = 0;
iterateListLike(collection, (item) => {
if (record === null || !looseIdentical(record.item, item)) {
record = this._mismatch(record, item, index);
mayBeDirty = true;
} else if (mayBeDirty) {
// TODO(misko): can we limit this to duplicates only?
record = this._verifyReinsertion(record, item, index);
}
record = record._next;
index++
});
this._length = index;the problem was this line sine var index:int, item;which is now var index:int = 0; |
5d4b3c1 to
e8bfaff
Compare
|
@mhevery I rebased and fixed the merge conflicts |
|
is there a better way to rebase on github? I always force push up changes after rebase but that also blows up any commits that were made in the files previously :/ |
e8bfaff to
d0eb5b4
Compare
There was a problem hiding this comment.
I also fixed the build in this commit foreach_spec.js#L127
|
In general I like this commit. You did make the change detection slower however. Those parts need to be reverted, but the rest can go. Please ping this thread once ready. |
d0eb5b4 to
ede0c68
Compare
|
The commit was squash without other changes. I also preserved the git history during renaming. There needs to be Iterator facade next and then a perf PR to avoid |
|
there are only a handful of iterables most people are going to use, it's not likely to result in IC misses if the path is only taken when the object is known statically to be iterable (would not necessarily "replace" Array change detection with Iterable change detection, though.) |
ede0c68 to
80610c6
Compare
|
gg yet another rebase and |
80610c6 to
bbf4db1
Compare
|
@mhevery PR is all green now with correct rebase and renames tracked by git |
rename: foreach -> for rename: array -> iterable update: DartParseTreeWriter update: naive_infinite_scroll update: todo fix: tests in foreach_spec
bbf4db1 to
c0f1d0f
Compare
|
@mhevery I rebase'd Master again so everything is green. If you have any suggestions or changes feel free to ping me again about it |
rename: foreach -> for rename: array -> iterable update: DartParseTreeWriter update: naive_infinite_scroll update: todo fix: tests in foreach_spec Closes #919
rename: foreach -> for rename: array -> iterable update: DartParseTreeWriter update: naive_infinite_scroll update: todo fix: tests in foreach_spec Closes #919
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Tests are passing. I also used
git mvto preserve the git history. I changed references with the name array to iterablecloses #909