simplifyDoWhileStatements() — react Function Reference
Architecture documentation for the simplifyDoWhileStatements() function in minimize.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD cac14331_ce33_094c_eaa6_0a52f5b76471["simplifyDoWhileStatements()"] 9c061da8_dbf8_4168_823d_991654a3c55d["minimize.ts"] cac14331_ce33_094c_eaa6_0a52f5b76471 -->|defined in| 9c061da8_dbf8_4168_823d_991654a3c55d 7a9af496_ef6a_d9e8_8eaf_1f386f49e4b3["cloneAst()"] cac14331_ce33_094c_eaa6_0a52f5b76471 -->|calls| 7a9af496_ef6a_d9e8_8eaf_1f386f49e4b3 style cac14331_ce33_094c_eaa6_0a52f5b76471 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/snap/src/minimize.ts lines 799–851
function* simplifyDoWhileStatements(ast: t.File): Generator<t.File> {
// Count do-while statements
let doWhileCount = 0;
t.traverseFast(ast, node => {
if (t.isDoWhileStatement(node)) {
doWhileCount++;
}
});
// Try replacing with test
for (let targetIdx = 0; targetIdx < doWhileCount; targetIdx++) {
const cloned = cloneAst(ast);
let idx = 0;
let modified = false;
traverse(cloned, {
DoWhileStatement(path) {
if (modified) return;
if (idx === targetIdx) {
path.replaceWith(t.expressionStatement(path.node.test));
modified = true;
}
idx++;
},
});
if (modified) {
yield cloned;
}
}
// Try replacing with body
for (let targetIdx = 0; targetIdx < doWhileCount; targetIdx++) {
const cloned = cloneAst(ast);
let idx = 0;
let modified = false;
traverse(cloned, {
DoWhileStatement(path) {
if (modified) return;
if (idx === targetIdx) {
path.replaceWith(path.node.body);
modified = true;
}
idx++;
},
});
if (modified) {
yield cloned;
}
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does simplifyDoWhileStatements() do?
simplifyDoWhileStatements() is a function in the react codebase, defined in compiler/packages/snap/src/minimize.ts.
Where is simplifyDoWhileStatements() defined?
simplifyDoWhileStatements() is defined in compiler/packages/snap/src/minimize.ts at line 799.
What does simplifyDoWhileStatements() call?
simplifyDoWhileStatements() calls 1 function(s): cloneAst.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free