From eff378defa9d59d4804593da9697223014a64198 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 9 Jun 2020 02:54:49 -0700 Subject: [PATCH] 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 --- desktop/app/src/plugins/TableNativePlugin.tsx | 2 +- desktop/plugins/network/RequestDetails.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/app/src/plugins/TableNativePlugin.tsx b/desktop/app/src/plugins/TableNativePlugin.tsx index 588eef420..e28c09b74 100644 --- a/desktop/app/src/plugins/TableNativePlugin.tsx +++ b/desktop/app/src/plugins/TableNativePlugin.tsx @@ -173,7 +173,7 @@ function buildRow( return { columns, key: rowData.id, - copyText: JSON.stringify(rowData), + copyText: () => JSON.stringify(rowData), filterValue: rowData.id, }; } diff --git a/desktop/plugins/network/RequestDetails.tsx b/desktop/plugins/network/RequestDetails.tsx index 07ee5c724..0c2e5e78b 100644 --- a/desktop/plugins/network/RequestDetails.tsx +++ b/desktop/plugins/network/RequestDetails.tsx @@ -780,7 +780,7 @@ class InsightsInspector extends Component<{insights: Insights}> { value: {formatter(value)}, }, }, - copyText: `${name}: ${formatter(value)}`, + copyText: () => `${name}: ${formatter(value)}`, key: name, } : null;