@@ -92,21 +92,13 @@ export class TreeNodeAccessor implements IHeapProfileNode {
92
92
}
93
93
}
94
94
95
- export const buildLeftHeavyColumns = ( model : IProfileModel ) : IColumn [ ] => {
96
- const tree = createTree ( model ) ;
97
-
98
- const columns : IColumn [ ] = [ ] ;
99
-
100
- let graphIdCounter = 0 ;
95
+ const getRawColumns = ( tree : ITreeNode ) => {
101
96
const cols : ITreeNode [ ] = [ ] ;
102
97
103
98
const getCols = ( node : ITreeNode ) => {
104
- for ( const key in node . children ) {
105
- if ( Object . prototype . hasOwnProperty . call ( node . children , key ) ) {
106
- const child = node . children [ key ] ;
107
- getCols ( child ) ;
108
- }
109
- }
99
+ Object . values ( node . children ) . forEach ( child => {
100
+ getCols ( child ) ;
101
+ } ) ;
110
102
111
103
if ( node . selfSize ) {
112
104
cols . push ( node ) ;
@@ -115,11 +107,20 @@ export const buildLeftHeavyColumns = (model: IProfileModel): IColumn[] => {
115
107
116
108
getCols ( tree ) ;
117
109
118
- cols . sort ( ( a , b ) => b . selfSize - a . selfSize ) ;
110
+ return cols ;
111
+ } ;
112
+
113
+ export const buildLeftHeavyColumns = ( model : IProfileModel ) : IColumn [ ] => {
114
+ const tree = createTree ( model ) ;
115
+ const rawColumns = getRawColumns ( tree ) ;
116
+ const columns : IColumn [ ] = [ ] ;
117
+
118
+ rawColumns . sort ( ( a , b ) => b . selfSize - a . selfSize ) ;
119
119
120
+ let graphIdCounter = 0 ;
120
121
let sizeOffset = 0 ;
121
- for ( let i = 0 ; i < cols . length ; i ++ ) {
122
- const root = cols [ i ] ;
122
+
123
+ for ( const root of rawColumns ) {
123
124
const rows = [
124
125
{
125
126
...root ,
@@ -160,30 +161,13 @@ export const buildLeftHeavyColumns = (model: IProfileModel): IColumn[] => {
160
161
*/
161
162
export const buildColumns = ( model : IProfileModel ) => {
162
163
const tree = createTree ( model ) ;
163
-
164
+ const rawColumns = getRawColumns ( tree ) ;
164
165
const columns : IColumn [ ] = [ ] ;
165
166
166
167
let graphIdCounter = 0 ;
167
- const cols : ITreeNode [ ] = [ ] ;
168
-
169
- const getCols = ( node : ITreeNode ) => {
170
- for ( const key in node . children ) {
171
- if ( Object . prototype . hasOwnProperty . call ( node . children , key ) ) {
172
- const child = node . children [ key ] ;
173
- getCols ( child ) ;
174
- }
175
- }
176
-
177
- if ( node . selfSize ) {
178
- cols . push ( node ) ;
179
- }
180
- } ;
181
-
182
- getCols ( tree ) ;
183
-
184
168
let sizeOffset = 0 ;
185
- for ( let i = 0 ; i < cols . length ; i ++ ) {
186
- const root = cols [ i ] ;
169
+
170
+ for ( const root of rawColumns ) {
187
171
const rows = [ ] ;
188
172
189
173
for ( let node : ITreeNode | undefined = root ; node ; node = node . parent ) {
0 commit comments