DisjointSet.ts — react Source File
Architecture documentation for DisjointSet.ts, a typescript file in the react codebase. 3 imports, 8 dependents.
Entity Profile
Dependency Diagram
graph LR edec7689_7b1d_03c9_9cbb_bb9b0552bc30["DisjointSet.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] edec7689_7b1d_03c9_9cbb_bb9b0552bc30 --> e96f281e_f381_272d_2359_3e6a091c9a1d e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] edec7689_7b1d_03c9_9cbb_bb9b0552bc30 --> e51fd0d2_bb38_cc97_7763_efe37f300a47 18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"] edec7689_7b1d_03c9_9cbb_bb9b0552bc30 --> 18a78965_f593_105b_e5e8_07001321c2ec 78244170_3d42_f86a_ea59_bce3e065fcfd["MergeOverlappingReactiveScopesHIR.ts"] 78244170_3d42_f86a_ea59_bce3e065fcfd --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30 6976a9ee_9d8e_4f16_3016_495f39aff2fd["PrintHIR.ts"] 6976a9ee_9d8e_4f16_3016_495f39aff2fd --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30 725143dd_a713_5e8e_fdf0_9c99de3b528f["InferReactivePlaces.ts"] 725143dd_a713_5e8e_fdf0_9c99de3b528f --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30 144792a6_40dd_95bb_1746_790346dbccd0["AlignMethodCallScopes.ts"] 144792a6_40dd_95bb_1746_790346dbccd0 --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30 ad600d8a_ade3_8a40_a17a_ccb4623a8608["AlignObjectMethodScopes.ts"] ad600d8a_ade3_8a40_a17a_ccb4623a8608 --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30 f041318d_301f_daad_4198_91d141b3039d["InferReactiveScopeVariables.ts"] f041318d_301f_daad_4198_91d141b3039d --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30 a4218b71_262a_ca43_13e7_98514ab3bd4e["PruneInitializationDependencies.ts"] a4218b71_262a_ca43_13e7_98514ab3bd4e --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30 8717d424_843c_a729_f999_954766189242["DisjointSet-test.ts"] 8717d424_843c_a729_f999_954766189242 --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30 style edec7689_7b1d_03c9_9cbb_bb9b0552bc30 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {CompilerError} from '../CompilerError';
import {GeneratedSource} from '../HIR/HIR';
// Represents items which form disjoint sets.
export default class DisjointSet<T> {
#entries: Map<T, T> = new Map();
/*
* Updates the graph to reflect that the given @param items form a set,
* linking any previous sets that the items were part of into a single
* set.
*/
union(items: Array<T>): void {
const first = items.shift();
CompilerError.invariant(first != null, {
reason: 'Expected set to be non-empty',
loc: GeneratedSource,
});
/*
* determine an arbitrary "root" for this set: if the first
* item already has a root then use that, otherwise the first item
* will be the new root.
*/
let root = this.find(first);
if (root == null) {
root = first;
this.#entries.set(first, first);
}
// update remaining items (which may already be part of other sets)
for (const item of items) {
let itemParent = this.#entries.get(item);
if (itemParent == null) {
// new item, no existing set to update
this.#entries.set(item, root);
continue;
} else if (itemParent === root) {
continue;
} else {
let current = item;
while (itemParent !== root) {
this.#entries.set(current, root);
current = itemParent;
itemParent = this.#entries.get(current)!;
}
}
}
}
/*
* Finds the set to which the given @param item is associated, if @param item
* is present in this set. If item is not present, returns null.
*
* Note that the returned value may be any item in the set to which the input
// ... (74 more lines)
Domain
Subdomains
Classes
Dependencies
Imported By
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AlignMethodCallScopes.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AlignObjectMethodScopes.ts
- compiler/packages/babel-plugin-react-compiler/src/__tests__/DisjointSet-test.ts
- compiler/packages/babel-plugin-react-compiler/src/Inference/InferReactivePlaces.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/InferReactiveScopeVariables.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneInitializationDependencies.ts
Source
Frequently Asked Questions
What does DisjointSet.ts do?
DisjointSet.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What does DisjointSet.ts depend on?
DisjointSet.ts imports 3 module(s): CompilerError, CompilerError.ts, HIR.ts.
What files import DisjointSet.ts?
DisjointSet.ts is imported by 8 file(s): AlignMethodCallScopes.ts, AlignObjectMethodScopes.ts, DisjointSet-test.ts, InferReactivePlaces.ts, InferReactiveScopeVariables.ts, MergeOverlappingReactiveScopesHIR.ts, PrintHIR.ts, PruneInitializationDependencies.ts.
Where is DisjointSet.ts in the architecture?
DisjointSet.ts is located at compiler/packages/babel-plugin-react-compiler/src/Utils/DisjointSet.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free