Commit 59524c69 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Slightly improve comments in SliverMultiBoxAdaptorElement (#10939)

I got a bit confused by these comments when trying to debug this code,
let's try clearing them up a little.
parent df1a01b3
......@@ -577,13 +577,20 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
performRebuild();
}
final SplayTreeMap<int, Element> _childElements = new SplayTreeMap<int, Element>();
// We inflate widgets at two different times:
// 1. When we ourselves are told to rebuild (see performRebuild).
// 2. When our render object needs a new child (see createChild).
// In both cases, we cache the results of calling into our delegate to get the widget,
// so that if we do case 2 later, we don't call the builder again.
// Any time we do case 1, though, we reset the cache.
final Map<int, Widget> _childWidgets = new HashMap<int, Widget>();
final SplayTreeMap<int, Element> _childElements = new SplayTreeMap<int, Element>();
RenderBox _currentBeforeChild;
@override
void performRebuild() {
_childWidgets.clear();
_childWidgets.clear(); // Reset the cache, as described above.
super.performRebuild();
_currentBeforeChild = null;
assert(_currentlyUpdatingChildIndex == null);
......@@ -596,9 +603,6 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
} else if (_didUnderflow) {
lastIndex += 1;
}
// We won't call the delegate's build function multiple times, because we
// cache the delegate's results until the next time we need to rebuild the
// whole widget.
for (int index = firstIndex; index <= lastIndex; ++index) {
_currentlyUpdatingChildIndex = index;
final Element newChild = updateChild(_childElements[index], _build(index), index);
......
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