Opened 14 years ago

Last modified 14 years ago

#7260 closed Bug

node.js -> getParents performance poor — at Version 2

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

Description (last modified by Krzysztof Studnik)

	getParents : function( closerFirst )
		{
			var node = this;
			var parents = [];

			do
			{
				parents[  closerFirst ? 'push' : 'unshift' ]( node );
			}
			while ( ( node = node.getParent() ) )

			return parents;
		},

unshift method performance poor

example code

	var t = +new Date,s = []
	for(var i = 0;i<1000;i++){
		s.push(i)
	};
	s.reverse();
	alert(+new Date - t) // 2

	var t = +new Date,s = []
	for(var i = 0;i<1000;i++){
		s.unshift(i)
	};

	alert(+new Date - t) //21

in ie8

Find this issue on GitHub

Change History (2)

comment:1 Changed 14 years ago by campaign

Component: GeneralPerformance

comment:2 Changed 14 years ago by Krzysztof Studnik

Description: modified (diff)
Keywords: HasPatch added

Please enclose code into code tags.

Find this issue on GitHub
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