mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[hir][be] Use a Map to store JsxExpression.props
Semantically this seems like a better fit as we're using Map like methods to iterate and update values anyway.
This commit is contained in:
@@ -860,7 +860,7 @@ function lowerExpression(
|
||||
const children = expr
|
||||
.get("children")
|
||||
.map((child) => lowerJsxElement(builder, child));
|
||||
const props: { [prop: string]: Place } = {};
|
||||
const props: Map<string, Place> = new Map();
|
||||
opening.get("attributes").forEach((attribute) => {
|
||||
todoInvariant(attribute.isJSXAttribute(), "handle spread attributes");
|
||||
const name = attribute.get("name");
|
||||
@@ -882,7 +882,7 @@ function lowerExpression(
|
||||
value = lowerExpressionToPlace(builder, expression);
|
||||
}
|
||||
const prop: string = name.node.name;
|
||||
props[prop] = value;
|
||||
props.set(prop, value);
|
||||
});
|
||||
return {
|
||||
kind: "JsxExpression",
|
||||
|
||||
@@ -215,7 +215,7 @@ function writeInstr(cx: Context, instr: Instruction, body: Array<t.Statement>) {
|
||||
}
|
||||
case "JsxExpression": {
|
||||
const attributes: Array<t.JSXAttribute> = [];
|
||||
for (const [prop, value] of Object.entries(instrValue.props)) {
|
||||
for (const [prop, value] of instrValue.props) {
|
||||
attributes.push(
|
||||
t.jsxAttribute(
|
||||
t.jsxIdentifier(prop),
|
||||
|
||||
@@ -185,7 +185,7 @@ export type InstructionData =
|
||||
| {
|
||||
kind: "JsxExpression";
|
||||
tag: Place;
|
||||
props: { [prop: string]: Place };
|
||||
props: Map<string, Place>;
|
||||
children: Array<Place> | null; // null === no children
|
||||
}
|
||||
| {
|
||||
|
||||
@@ -546,7 +546,7 @@ function inferBlock(env: Environment, block: BasicBlock) {
|
||||
case "JsxExpression": {
|
||||
valueKind = ValueKind.Frozen;
|
||||
env.reference(instrValue.tag, Effect.Freeze);
|
||||
for (const [_prop, value] of Object.entries(instrValue.props)) {
|
||||
for (const [_prop, value] of instrValue.props) {
|
||||
env.reference(value, Effect.Freeze);
|
||||
}
|
||||
if (instrValue.children !== null) {
|
||||
|
||||
@@ -191,7 +191,7 @@ function printInstructionValue(instrValue: InstructionValue): string {
|
||||
}
|
||||
case "JsxExpression": {
|
||||
const propItems = [];
|
||||
for (const [prop, value] of Object.entries(instrValue.props)) {
|
||||
for (const [prop, value] of instrValue.props) {
|
||||
propItems.push(`${prop}={${printPlace(value)}}`);
|
||||
}
|
||||
const props = propItems.length !== 0 ? " " + propItems.join(" ") : "";
|
||||
|
||||
Reference in New Issue
Block a user