Commit 6fa6e04a authored by Mike Bostock's avatar Mike Bostock
Browse files

Remember last non-null following sibling.

This way, we don’t rescan the same null elements.
parent 99f6e657
......@@ -924,9 +924,12 @@ d3 = function() {
return d3_selectionPrototype.insert.call(this, name, before);
};
function d3_selection_enterInsertBefore(enter) {
var i0, j0;
return function(d, i, j) {
var group = enter[j].update, n = group.length, node;
while (++i < n && !(node = group[i])) ;
if (j != j0) j0 = j, i0 = 0;
if (i >= i0) i0 = i + 1;
while (!(node = group[i0]) && ++i0 < n) ;
return node;
};
}
......
This diff is collapsed.
......@@ -7,11 +7,14 @@ d3_selection_enterPrototype.insert = function(name, before) {
};
function d3_selection_enterInsertBefore(enter) {
var i0, j0;
return function(d, i, j) {
var group = enter[j].update,
n = group.length,
node;
while (++i < n && !(node = group[i]));
if (j != j0) j0 = j, i0 = 0;
if (i >= i0) i0 = i + 1;
while (!(node = group[i0]) && ++i0 < n);
return node;
};
}
......@@ -120,7 +120,7 @@ suite.addBatch({
return body;
},
"inserts before the following updating sibling": function(body) {
var data = ["peach", "apple", "banana", "orange", "apricot"];
var data = ["peach", "apple", "apple2", "apple3", "banana", "orange", "apricot"];
body.selectAll("div").data(data, String).enter().insert("div");
assert.deepEqual(body.selectAll("div").data(), data);
}
......
Supports Markdown
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