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 ) ¶
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

Change History (2)
comment:1 Changed 14 years ago by
Component: | General → Performance |
---|
comment:2 Changed 14 years ago by
Description: | modified (diff) |
---|---|
Keywords: | HasPatch added |

Please enclose code into
code
tags.