File tree Expand file tree Collapse file tree 5 files changed +33
-23
lines changed
react-devtools-shared/src/backend Expand file tree Collapse file tree 5 files changed +33
-23
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export function createProfilingHooks({
7575 reactVersion,
7676} : { |
7777 getDisplayNameForFiber : ( fiber : Fiber ) => string | null ,
78- getLaneLabelMap ? : ( ) => Map < Lane , string > ,
78+ getLaneLabelMap ? : ( ) => Map < Lane , string > | null ,
7979 reactVersion : string ,
8080| } ) : DevToolsProfilingHooks {
8181 function markMetadata ( ) {
@@ -108,8 +108,10 @@ export function createProfilingHooks({
108108
109109 if ( typeof getLaneLabelMap === 'function' ) {
110110 const map = getLaneLabelMap ( ) ;
111- const labels = Array . from ( map . values ( ) ) . join ( ',' ) ;
112- markAndClear ( `--react-lane-labels-${ labels } ` ) ;
111+ if ( map != null ) {
112+ const labels = Array . from ( map . values ( ) ) . join ( ',' ) ;
113+ markAndClear ( `--react-lane-labels-${ labels } ` ) ;
114+ }
113115 }
114116 }
115117
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ export type ReactRenderer = {
152152 scheduleRefresh ?: Function ,
153153 // 18.0+
154154 injectProfilingHooks ?: ( profilingHooks : DevToolsProfilingHooks ) => void ,
155- getLaneLabelMap ?: ( ) => Map < Lane , string > ,
155+ getLaneLabelMap ?: ( ) => Map < Lane , string > | null ,
156156 ...
157157} ;
158158
Original file line number Diff line number Diff line change @@ -230,17 +230,21 @@ function injectProfilingHooks(profilingHooks: DevToolsProfilingHooks): void {
230230 injectedProfilingHooks = profilingHooks ;
231231}
232232
233- function getLaneLabelMap ( ) : Map < Lane , string > {
234- const map : Map < Lane , string > = new Map ( ) ;
233+ function getLaneLabelMap ( ) : Map < Lane , string > | null {
234+ if ( enableSchedulingProfiler ) {
235+ const map : Map < Lane , string > = new Map ( ) ;
235236
236- let lane = 1 ;
237- for ( let index = 0 ; index < TotalLanes ; index ++ ) {
238- const label = ( ( getLabelForLane ( lane ) : any ) : string ) ;
239- map . set ( lane , label ) ;
240- lane *= 2 ;
241- }
237+ let lane = 1 ;
238+ for ( let index = 0 ; index < TotalLanes ; index ++ ) {
239+ const label = ( ( getLabelForLane ( lane ) : any ) : string ) ;
240+ map . set ( lane , label ) ;
241+ lane *= 2 ;
242+ }
242243
243- return map ;
244+ return map ;
245+ } else {
246+ return null ;
247+ }
244248}
245249
246250export function markCommitStarted ( lanes : Lanes ) : void {
Original file line number Diff line number Diff line change @@ -230,17 +230,21 @@ function injectProfilingHooks(profilingHooks: DevToolsProfilingHooks): void {
230230 injectedProfilingHooks = profilingHooks ;
231231}
232232
233- function getLaneLabelMap ( ) : Map < Lane , string > {
234- const map : Map < Lane , string > = new Map ( ) ;
233+ function getLaneLabelMap ( ) : Map < Lane , string > | null {
234+ if ( enableSchedulingProfiler ) {
235+ const map : Map < Lane , string > = new Map ( ) ;
235236
236- let lane = 1 ;
237- for ( let index = 0 ; index < TotalLanes ; index ++ ) {
238- const label = ( ( getLabelForLane ( lane ) : any ) : string ) ;
239- map . set ( lane , label ) ;
240- lane *= 2 ;
241- }
237+ let lane = 1 ;
238+ for ( let index = 0 ; index < TotalLanes ; index ++ ) {
239+ const label = ( ( getLabelForLane ( lane ) : any ) : string ) ;
240+ map . set ( lane , label ) ;
241+ lane *= 2 ;
242+ }
242243
243- return map ;
244+ return map ;
245+ } else {
246+ return null ;
247+ }
244248}
245249
246250export function markCommitStarted ( lanes : Lanes ) : void {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import typeof * as ExportsType from './ReactFeatureFlags.testing';
1212
1313export const debugRenderPhaseSideEffectsForStrictMode = false ;
1414export const enableDebugTracing = false ;
15- export const enableSchedulingProfiler = false ;
15+ export const enableSchedulingProfiler = __PROFILE__ ;
1616export const warnAboutDeprecatedLifecycles = true ;
1717export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false ;
1818export const enableProfilerTimer = __PROFILE__ ;
You can’t perform that action at this time.
0 commit comments