Add comment about ideally not relying on parent.children.indexOf for getIndex().

This commit is contained in:
Jürg Lehni 2011-02-13 18:51:49 +00:00
parent eeb7d377e6
commit 604ff7824c

View file

@ -1,5 +1,6 @@
Item = Base.extend({
beans: true,
initialize: function() {
this.parent = Paper.document.activeLayer;
this.parent.children.push(this);
@ -155,7 +156,7 @@ Item = Base.extend({
getNextSibling: function() {
if (this.parent) {
var index = this.index + 1;
if (index < this.parent.children.length)
if (index < this.parent.children.length)
return this.parent.children[index];
}
},
@ -175,6 +176,9 @@ Item = Base.extend({
* The index of this item within the list of it's parent's children.
*/
getIndex: function() {
// TODO: Relying on indexOf() here is slow, especially since it is
// used for getPrevious/NextSibling().
// We need linked lists instead.
return this.parent.children.indexOf(this);
},