Commit 1e61314e authored by Ian Hickson's avatar Ian Hickson

Merge pull request #897 from Hixie/sync-children

Provide a fast path for MultiChildRenderObjectWrapper.syncRenderObject() when the children lists are identical.
parents 5fb31769 204c0736
......@@ -998,6 +998,9 @@ abstract class RenderObjectWrapper extends Widget {
// for use by subclasses that manage their children using lists
void syncChildren(List<Widget> newChildren, List<Widget> oldChildren) {
assert(newChildren != null);
assert(oldChildren != null);
assert(!identical(newChildren, oldChildren));
// This attempts to diff the new child list (this.children) with
// the old child list (old.children), and update our renderObject
......@@ -1257,7 +1260,19 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
void syncRenderObject(MultiChildRenderObjectWrapper old) {
super.syncRenderObject(old);
syncChildren(children, old == null ? const <Widget>[] : old.children);
List<Widget> oldChildren = old == null ? const <Widget>[] : old.children;
if (oldChildren == children) {
int index = children.length;
Widget nextSibling = null;
while (index > 0) {
index -= 1;
Widget child = children[index];
nextSibling = syncChild(child, child, nextSibling);
children[index] = nextSibling;
}
} else {
syncChildren(children, oldChildren);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment