Home / Class/ MergedBlocks Class — react Architecture

MergedBlocks Class — react Architecture

Architecture documentation for the MergedBlocks class in MergeConsecutiveBlocks.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  1a8360d2_10af_e1f2_29f7_8712f3ff9cbe["MergedBlocks"]
  010bd3a7_d091_50ea_4e1f_20541d841f85["MergeConsecutiveBlocks.ts"]
  1a8360d2_10af_e1f2_29f7_8712f3ff9cbe -->|defined in| 010bd3a7_d091_50ea_4e1f_20541d841f85
  15ce5dd6_b99d_ce73_8748_87fb1267ffd7["merge()"]
  1a8360d2_10af_e1f2_29f7_8712f3ff9cbe -->|method| 15ce5dd6_b99d_ce73_8748_87fb1267ffd7
  c037181b_4cfb_039c_81d1_8f129348cda7["get()"]
  1a8360d2_10af_e1f2_29f7_8712f3ff9cbe -->|method| c037181b_4cfb_039c_81d1_8f129348cda7

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/MergeConsecutiveBlocks.ts lines 125–146

class MergedBlocks {
  #map: Map<BlockId, BlockId> = new Map();

  // Record that @param block was merged into @param into.
  merge(block: BlockId, into: BlockId): void {
    const target = this.get(into);
    this.#map.set(block, target);
  }

  /*
   * Get the id of the block that @param block has been merged into.
   * This is transitive, in the case that eg @param block was merged
   * into a block which later merged into another block.
   */
  get(block: BlockId): BlockId {
    let current = block;
    while (this.#map.has(current)) {
      current = this.#map.get(current) ?? current;
    }
    return current;
  }
}

Frequently Asked Questions

What is the MergedBlocks class?
MergedBlocks is a class in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/MergeConsecutiveBlocks.ts.
Where is MergedBlocks defined?
MergedBlocks is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/MergeConsecutiveBlocks.ts at line 125.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free