Skip to content

Commit f621c97

Browse files
committed
Inline three borderline wing helpers.
1 parent bfd68c8 commit f621c97

2 files changed

Lines changed: 61 additions & 81 deletions

File tree

src/components/calltree/WingTreeView.tsx

Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -321,44 +321,6 @@ class WingTreeViewImpl extends PureComponent<Props> {
321321
}
322322
}
323323

324-
// Build the StateProps for a given wing. Both wings have the same prop
325-
// shape; only the wing-specific selector identifiers differ.
326-
function makeMapStateToProps(
327-
getView: (state: State) => WingViewType,
328-
selectors: {
329-
getCallTree: (state: State) => CallTreeType;
330-
getCallNodeInfo: (state: State) => CallNodeInfo;
331-
getSelectedCallNodeIndex: (state: State) => IndexIntoCallNodeTable | null;
332-
getRightClickedCallNodeIndex: (
333-
state: State
334-
) => IndexIntoCallNodeTable | null;
335-
getExpandedCallNodeIndexes: (
336-
state: State
337-
) => Array<IndexIntoCallNodeTable | null>;
338-
}
339-
) {
340-
return (state: State): StateProps => ({
341-
threadsKey: getSelectedThreadsKey(state),
342-
scrollToSelectionGeneration: getScrollToSelectionGeneration(state),
343-
tree: selectors.getCallTree(state),
344-
callNodeInfo: selectors.getCallNodeInfo(state),
345-
categories: getCategories(state),
346-
selectedCallNodeIndex: selectors.getSelectedCallNodeIndex(state),
347-
rightClickedCallNodeIndex: selectors.getRightClickedCallNodeIndex(state),
348-
expandedCallNodeIndexes: selectors.getExpandedCallNodeIndexes(state),
349-
searchStringsRegExp: getSearchStringsAsRegExp(state),
350-
disableOverscan: getPreviewSelectionIsBeingModified(state),
351-
// Use the filtered call node max depth, rather than the preview filtered
352-
// call node max depth so that the width of the TreeView component is stable
353-
// across preview selections.
354-
callNodeMaxDepthPlusOne:
355-
selectedThreadSelectors.getFilteredCallNodeMaxDepthPlusOne(state),
356-
weightType: selectedThreadSelectors.getWeightTypeForCallTree(state),
357-
tableViewOptions: getCurrentTableViewOptions(state),
358-
view: getView(state),
359-
});
360-
}
361-
362324
function makeMapDispatchToProps(wing: WingName) {
363325
return {
364326
changeSelectedCallNode: (
@@ -415,30 +377,53 @@ function LowerWingComponent(
415377
}
416378

417379
export const UpperWing = explicitConnect<{}, StateProps, DispatchProps>({
418-
mapStateToProps: makeMapStateToProps(getUpperWingView, {
419-
getCallTree: selectedThreadSelectors.getUpperWingCallTree,
420-
getCallNodeInfo: selectedThreadSelectors.getUpperWingCallNodeInfo,
421-
getSelectedCallNodeIndex:
422-
selectedThreadSelectors.getUpperWingSelectedCallNodeIndex,
423-
getRightClickedCallNodeIndex:
424-
selectedThreadSelectors.getUpperWingRightClickedCallNodeIndex,
425-
getExpandedCallNodeIndexes:
426-
selectedThreadSelectors.getUpperWingExpandedCallNodeIndexes,
380+
mapStateToProps: (state: State): StateProps => ({
381+
threadsKey: getSelectedThreadsKey(state),
382+
scrollToSelectionGeneration: getScrollToSelectionGeneration(state),
383+
tree: selectedThreadSelectors.getUpperWingCallTree(state),
384+
callNodeInfo: selectedThreadSelectors.getUpperWingCallNodeInfo(state),
385+
categories: getCategories(state),
386+
selectedCallNodeIndex:
387+
selectedThreadSelectors.getUpperWingSelectedCallNodeIndex(state),
388+
rightClickedCallNodeIndex:
389+
selectedThreadSelectors.getUpperWingRightClickedCallNodeIndex(state),
390+
expandedCallNodeIndexes:
391+
selectedThreadSelectors.getUpperWingExpandedCallNodeIndexes(state),
392+
searchStringsRegExp: getSearchStringsAsRegExp(state),
393+
disableOverscan: getPreviewSelectionIsBeingModified(state),
394+
// Use the filtered call node max depth, rather than the preview filtered
395+
// call node max depth so that the width of the TreeView component is stable
396+
// across preview selections.
397+
callNodeMaxDepthPlusOne:
398+
selectedThreadSelectors.getFilteredCallNodeMaxDepthPlusOne(state),
399+
weightType: selectedThreadSelectors.getWeightTypeForCallTree(state),
400+
tableViewOptions: getCurrentTableViewOptions(state),
401+
view: getUpperWingView(state),
427402
}),
428403
mapDispatchToProps: makeMapDispatchToProps('upper'),
429404
component: UpperWingComponent,
430405
});
431406

432407
export const LowerWing = explicitConnect<{}, StateProps, DispatchProps>({
433-
mapStateToProps: makeMapStateToProps(getLowerWingView, {
434-
getCallTree: selectedThreadSelectors.getLowerWingCallTree,
435-
getCallNodeInfo: selectedThreadSelectors.getLowerWingCallNodeInfo,
436-
getSelectedCallNodeIndex:
437-
selectedThreadSelectors.getLowerWingSelectedCallNodeIndex,
438-
getRightClickedCallNodeIndex:
439-
selectedThreadSelectors.getLowerWingRightClickedCallNodeIndex,
440-
getExpandedCallNodeIndexes:
441-
selectedThreadSelectors.getLowerWingExpandedCallNodeIndexes,
408+
mapStateToProps: (state: State): StateProps => ({
409+
threadsKey: getSelectedThreadsKey(state),
410+
scrollToSelectionGeneration: getScrollToSelectionGeneration(state),
411+
tree: selectedThreadSelectors.getLowerWingCallTree(state),
412+
callNodeInfo: selectedThreadSelectors.getLowerWingCallNodeInfo(state),
413+
categories: getCategories(state),
414+
selectedCallNodeIndex:
415+
selectedThreadSelectors.getLowerWingSelectedCallNodeIndex(state),
416+
rightClickedCallNodeIndex:
417+
selectedThreadSelectors.getLowerWingRightClickedCallNodeIndex(state),
418+
expandedCallNodeIndexes:
419+
selectedThreadSelectors.getLowerWingExpandedCallNodeIndexes(state),
420+
searchStringsRegExp: getSearchStringsAsRegExp(state),
421+
disableOverscan: getPreviewSelectionIsBeingModified(state),
422+
callNodeMaxDepthPlusOne:
423+
selectedThreadSelectors.getFilteredCallNodeMaxDepthPlusOne(state),
424+
weightType: selectedThreadSelectors.getWeightTypeForCallTree(state),
425+
tableViewOptions: getCurrentTableViewOptions(state),
426+
view: getLowerWingView(state),
442427
}),
443428
mapDispatchToProps: makeMapDispatchToProps('lower'),
444429
component: LowerWingComponent,

src/selectors/per-thread/stack-sample.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,6 @@ export function getStackAndSampleSelectorsPerThread(
243243
ProfileData.getLowerWingCallNodeInfo
244244
);
245245

246-
// Returns the selected call node path stored under the given area in this
247-
// thread's ThreadViewOptions.
248-
const makeSelectedPathSelector = (
249-
area: CallNodeArea
250-
): Selector<CallNodePath> =>
251-
createSelector(
252-
threadSelectors.getViewOptions,
253-
(threadViewOptions) => threadViewOptions.selectedCallNodePaths[area]
254-
);
255-
256-
// Returns the expanded call node paths stored under the given area.
257-
const makeExpandedPathsSelector = (area: CallNodeArea): Selector<PathSet> =>
258-
createSelector(
259-
threadSelectors.getViewOptions,
260-
(threadViewOptions) => threadViewOptions.expandedCallNodePaths[area]
261-
);
262-
263246
// Combines a CallNodeInfo selector with a CallNodePath selector to produce
264247
// the corresponding call node index.
265248
const makeCallNodeIndexFromPathSelector = (
@@ -282,10 +265,17 @@ export function getStackAndSampleSelectorsPerThread(
282265
)
283266
);
284267

285-
const getLowerWingSelectedCallNodePath =
286-
makeSelectedPathSelector('LOWER_WING');
287-
const getUpperWingSelectedCallNodePath =
288-
makeSelectedPathSelector('UPPER_WING');
268+
const getLowerWingSelectedCallNodePath: Selector<CallNodePath> =
269+
createSelector(
270+
threadSelectors.getViewOptions,
271+
(threadViewOptions) => threadViewOptions.selectedCallNodePaths.LOWER_WING
272+
);
273+
274+
const getUpperWingSelectedCallNodePath: Selector<CallNodePath> =
275+
createSelector(
276+
threadSelectors.getViewOptions,
277+
(threadViewOptions) => threadViewOptions.selectedCallNodePaths.UPPER_WING
278+
);
289279

290280
const getSelectedCallNodePath: Selector<CallNodePath> = createSelector(
291281
threadSelectors.getViewOptions,
@@ -318,10 +308,15 @@ export function getStackAndSampleSelectorsPerThread(
318308
: threadViewOptions.expandedCallNodePaths.NON_INVERTED_TREE
319309
);
320310

321-
const getLowerWingExpandedCallNodePaths =
322-
makeExpandedPathsSelector('LOWER_WING');
323-
const getUpperWingExpandedCallNodePaths =
324-
makeExpandedPathsSelector('UPPER_WING');
311+
const getLowerWingExpandedCallNodePaths: Selector<PathSet> = createSelector(
312+
threadSelectors.getViewOptions,
313+
(threadViewOptions) => threadViewOptions.expandedCallNodePaths.LOWER_WING
314+
);
315+
316+
const getUpperWingExpandedCallNodePaths: Selector<PathSet> = createSelector(
317+
threadSelectors.getViewOptions,
318+
(threadViewOptions) => threadViewOptions.expandedCallNodePaths.UPPER_WING
319+
);
325320

326321
const getExpandedCallNodeIndexes = makeExpandedIndexesSelector(
327322
getCallNodeInfo,

0 commit comments

Comments
 (0)