| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 }); | 93 }); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * Traverses profile view nodes in preorder. | 98 * Traverses profile view nodes in preorder. |
| 99 * | 99 * |
| 100 * @param {function(devtools.profiler.ProfileView.Node)} f Visitor function. | 100 * @param {function(devtools.profiler.ProfileView.Node)} f Visitor function. |
| 101 */ | 101 */ |
| 102 devtools.profiler.ProfileView.prototype.traverse = function(f) { | 102 devtools.profiler.ProfileView.prototype.traverse = function(f) { |
| 103 var nodesToTraverse = [this.head]; | 103 var nodesToTraverse = new ConsArray(); |
| 104 while (nodesToTraverse.length > 0) { | 104 nodesToTraverse.concat([this.head]); |
| 105 var node = nodesToTraverse.shift(); | 105 while (!nodesToTraverse.atEnd()) { |
| 106 var node = nodesToTraverse.next(); |
| 106 f(node); | 107 f(node); |
| 107 nodesToTraverse = nodesToTraverse.concat(node.children); | 108 nodesToTraverse.concat(node.children); |
| 108 } | 109 } |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * Constructs a Profile View node object. Each node object corresponds to | 114 * Constructs a Profile View node object. Each node object corresponds to |
| 114 * a function call. | 115 * a function call. |
| 115 * | 116 * |
| 116 * @param {string} internalFuncName A fully qualified function name. | 117 * @param {string} internalFuncName A fully qualified function name. |
| 117 * @param {number} totalTime Amount of time that application spent in the | 118 * @param {number} totalTime Amount of time that application spent in the |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 * Sorts all the node's children recursively. | 176 * Sorts all the node's children recursively. |
| 176 * | 177 * |
| 177 * @param {function(devtools.profiler.ProfileView.Node, | 178 * @param {function(devtools.profiler.ProfileView.Node, |
| 178 * devtools.profiler.ProfileView.Node):number} sortFunc A sorting | 179 * devtools.profiler.ProfileView.Node):number} sortFunc A sorting |
| 179 * functions. Must comply with Array.sort sorting function requirements. | 180 * functions. Must comply with Array.sort sorting function requirements. |
| 180 */ | 181 */ |
| 181 devtools.profiler.ProfileView.Node.prototype.sortChildren = function( | 182 devtools.profiler.ProfileView.Node.prototype.sortChildren = function( |
| 182 sortFunc) { | 183 sortFunc) { |
| 183 this.children.sort(sortFunc); | 184 this.children.sort(sortFunc); |
| 184 }; | 185 }; |
| OLD | NEW |