Avoid JSON.stingify during render
Summary: See previous diffs, same change as with analytics, don't stringify when creating the rows, but rather provide a closure to do that lazily, which reduces CPU (and mem) usage. Note that this implicitly assumes the captures variables are immutable, as otherwise the semantics would change. But than again, if those variables are changed in the future, copyText will reflect their latest rather than initial state, which is better anyway. Reviewed By: nikoant Differential Revision: D21931748 fbshipit-source-id: 62325dd25953bab3a4e2e9a0d5dea3b3a7787bae
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3033fb035c
commit
eff378defa
@@ -173,7 +173,7 @@ function buildRow(
|
|||||||
return {
|
return {
|
||||||
columns,
|
columns,
|
||||||
key: rowData.id,
|
key: rowData.id,
|
||||||
copyText: JSON.stringify(rowData),
|
copyText: () => JSON.stringify(rowData),
|
||||||
filterValue: rowData.id,
|
filterValue: rowData.id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ class InsightsInspector extends Component<{insights: Insights}> {
|
|||||||
value: <WrappingText>{formatter(value)}</WrappingText>,
|
value: <WrappingText>{formatter(value)}</WrappingText>,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
copyText: `${name}: ${formatter(value)}`,
|
copyText: () => `${name}: ${formatter(value)}`,
|
||||||
key: name,
|
key: name,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
|||||||
Reference in New Issue
Block a user