Opened 13 years ago

Last modified 13 years ago

#7067 confirmed Bug

about getIndex method performance

Reported by: campaign Owned by:
Priority: Normal Milestone:
Component: Performance Version:
Keywords: HasPatch Cc:

Description (last modified by Garry Yao)

When the getIndex method is called, the getNext will be invoked by getIndex, if an element node contains too many text nodes, the getNext method will be called too many times, that will cause a performance problem. My suggest is using childNodes property, according to my test, using childNodes is nearly two times faster than calling getNext method. Here's my code snippet:

getIndex : function( normalized ) {

var parent = this.getParent(),

currentIndex = -1, node;

if ( parent ) {

for(var i=0,childs=parent.$.childNodes;node=childs[i];i++){

if(node.nodeType == 1
!(normalized && node.previousSibling && node.previousSibling.nodeType == baidu.editor.dom.NODE_TEXT))


if(node == this.$)break;


} return currentIndex;


Change History (2)

comment:1 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Keywords: HasPatch added

comment:2 Changed 13 years ago by Garry Yao

Component: GeneralPerformance
Description: modified (diff)
Status: newconfirmed
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy