44
55import * as React from 'react' ;
66import { PureComponent } from 'react' ;
7- import memoize from 'memoize-immutable' ;
87import explicitConnect from 'firefox-profiler/utils/connect' ;
98import { TreeView } from 'firefox-profiler/components/shared/TreeView' ;
109import { CallTreeEmptyReasons } from './CallTreeEmptyReasons' ;
@@ -17,9 +16,9 @@ import {
1716 type LowerWingFlameGraphHandle ,
1817} from './LowerWingFlameGraph' ;
1918import {
20- treeColumnsForTracingMs ,
21- treeColumnsForSamples ,
22- treeColumnsForBytes ,
19+ mainColumn ,
20+ appendageColumn ,
21+ treeColumnsForWeightType ,
2322} from './columns' ;
2423import {
2524 getSearchStringsAsRegExp ,
@@ -43,8 +42,6 @@ import {
4342 changeTableViewOptions ,
4443 updateBottomBoxContentsAndMaybeOpen ,
4544} from 'firefox-profiler/actions/profile-view' ;
46- import { assertExhaustiveCheck } from 'firefox-profiler/utils/types' ;
47-
4845import type {
4946 State ,
5047 ThreadsKey ,
@@ -61,10 +58,6 @@ import type {
6158import type { CallTree as CallTreeType } from 'firefox-profiler/profile-logic/call-tree' ;
6259import type { CallNodeInfo } from 'firefox-profiler/profile-logic/call-node-info' ;
6360
64- import type {
65- Column ,
66- MaybeResizableColumn ,
67- } from 'firefox-profiler/components/shared/TreeView' ;
6861import type { ConnectedProps } from 'firefox-profiler/utils/connect' ;
6962
7063import './CallTree.css' ;
@@ -122,42 +115,13 @@ type WingConfigProps = {
122115type Props = ConnectedProps < { } , StateProps , DispatchProps > & WingConfigProps ;
123116
124117class WingTreeViewImpl extends PureComponent < Props > {
125- _mainColumn : Column < CallNodeDisplayData > = {
126- propName : 'name' ,
127- titleL10nId : '' ,
128- } ;
129- _appendageColumn : Column < CallNodeDisplayData > = {
130- propName : 'lib' ,
131- titleL10nId : '' ,
132- } ;
133118 _treeView : TreeView < CallNodeDisplayData > | null = null ;
134119 _takeTreeViewRef = ( treeView : TreeView < CallNodeDisplayData > | null ) => {
135120 this . _treeView = treeView ;
136121 } ;
137122 _flameGraphRef : React . RefObject < WingFlameGraphHandle | null > =
138123 React . createRef ( ) ;
139124
140- /**
141- * Call Trees can have different types of "weights" for the data. Choose the
142- * appropriate labels for the call tree based on this weight.
143- */
144- _weightTypeToColumns = memoize (
145- ( weightType : WeightType ) : MaybeResizableColumn < CallNodeDisplayData > [ ] => {
146- switch ( weightType ) {
147- case 'tracing-ms' :
148- return treeColumnsForTracingMs ;
149- case 'samples' :
150- return treeColumnsForSamples ;
151- case 'bytes' :
152- return treeColumnsForBytes ;
153- default :
154- throw assertExhaustiveCheck ( weightType , 'Unhandled WeightType.' ) ;
155- }
156- } ,
157- // Use a Map cache, as the function only takes one argument, which is a simple string.
158- { cache : new Map ( ) }
159- ) ;
160-
161125 override componentDidMount ( ) {
162126 this . focus ( ) ;
163127 this . maybeProcureInterestingInitialSelection ( ) ;
@@ -324,9 +288,9 @@ class WingTreeViewImpl extends PureComponent<Props> {
324288 return (
325289 < TreeView
326290 tree = { tree }
327- fixedColumns = { this . _weightTypeToColumns ( weightType ) }
328- mainColumn = { this . _mainColumn }
329- appendageColumn = { this . _appendageColumn }
291+ fixedColumns = { treeColumnsForWeightType ( weightType ) }
292+ mainColumn = { mainColumn }
293+ appendageColumn = { appendageColumn }
330294 onSelectionChange = { this . _onSelectedCallNodeChange }
331295 onRightClickSelection = { this . _onRightClickSelection }
332296 onExpandedNodesChange = { this . _onExpandedCallNodesChange }
0 commit comments