@@ -1622,18 +1622,25 @@ export function attach(
1622
1622
pendingOperations . push ( op ) ;
1623
1623
}
1624
1624
1625
- function flushOrQueueOperations ( operations : OperationsArray ) : void {
1626
- if ( operations . length === 3 ) {
1627
- // This operations array is a no op: [renderer ID, root ID, string table size (0)]
1628
- // We can usually skip sending updates like this across the bridge, unless we're Profiling.
1629
- // In that case, even though the tree didn't change– some Fibers may have still rendered.
1630
- if (
1631
- ! isProfiling ||
1625
+ function shouldBailoutWithPendingOperations ( ) {
1626
+ if ( ! isProfiling ) {
1627
+ return (
1628
+ pendingOperations . length === 0 &&
1629
+ pendingRealUnmountedIDs . length === 0 &&
1630
+ pendingSimulatedUnmountedIDs . length === 0 &&
1631
+ pendingUnmountedRootID === null
1632
+ ) ;
1633
+ } else {
1634
+ return (
1632
1635
currentCommitProfilingMetadata == null ||
1633
1636
currentCommitProfilingMetadata . durations . length === 0
1634
- ) {
1635
- return ;
1636
- }
1637
+ ) ;
1638
+ }
1639
+ }
1640
+
1641
+ function flushOrQueueOperations ( operations : OperationsArray ) : void {
1642
+ if ( shouldBailoutWithPendingOperations ( ) ) {
1643
+ return ;
1637
1644
}
1638
1645
1639
1646
if ( pendingOperationsQueue !== null ) {
@@ -1666,7 +1673,7 @@ export function attach(
1666
1673
1667
1674
recordPendingErrorsAndWarnings ( ) ;
1668
1675
1669
- if ( pendingOperations . length === 0 ) {
1676
+ if ( shouldBailoutWithPendingOperations ( ) ) {
1670
1677
// No warnings or errors to flush; we can bail out early here too.
1671
1678
return ;
1672
1679
}
@@ -1789,12 +1796,7 @@ export function attach(
1789
1796
// We do this just before flushing, so we can ignore errors for no-longer-mounted Fibers.
1790
1797
recordPendingErrorsAndWarnings ( ) ;
1791
1798
1792
- if (
1793
- pendingOperations . length === 0 &&
1794
- pendingRealUnmountedIDs . length === 0 &&
1795
- pendingSimulatedUnmountedIDs . length === 0 &&
1796
- pendingUnmountedRootID === null
1797
- ) {
1799
+ if ( shouldBailoutWithPendingOperations ( ) ) {
1798
1800
// If we aren't profiling, we can just bail out here.
1799
1801
// No use sending an empty update over the bridge.
1800
1802
//
@@ -1803,9 +1805,7 @@ export function attach(
1803
1805
// (2) the operations array for each commit
1804
1806
// Because of this, it's important that the operations and metadata arrays align,
1805
1807
// So it's important not to omit even empty operations while profiling is active.
1806
- if ( ! isProfiling ) {
1807
- return ;
1808
- }
1808
+ return ;
1809
1809
}
1810
1810
1811
1811
const numUnmountIDs =
@@ -2722,12 +2722,7 @@ export function attach(
2722
2722
}
2723
2723
2724
2724
if ( isProfiling && isProfilingSupported ) {
2725
- // Make sure at least one Fiber performed work during this commit.
2726
- // If not, don't send it to the frontend; showing an empty commit in the Profiler is confusing.
2727
- if (
2728
- currentCommitProfilingMetadata != null &&
2729
- currentCommitProfilingMetadata . durations . length > 0
2730
- ) {
2725
+ if ( ! shouldBailoutWithPendingOperations ( ) ) {
2731
2726
const commitProfilingMetadata = ( ( rootToCommitProfilingMetadataMap : any ) : CommitProfilingMetadataMap ) . get (
2732
2727
currentRootID ,
2733
2728
) ;
0 commit comments