Evaluate copyText lazily
Summary: `copyText` is generated when building rows for table, and is typically filled by JSON stringifying the incoming data. That is a pretty expensive process that could be done lazily. As shown in later diffs, this reduces the generation of rows for tables from ~18ms to ~3ms, which makes rendering a lot smoother. (n.b. fixing the code duplication in the managedtables is part of the component lib plan) Reviewed By: passy Differential Revision: D21929660 fbshipit-source-id: 67cc69945e2bb28a6462a9d9ab765e33ced89378
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2375dd02c3
commit
3033fb035c
@@ -575,9 +575,10 @@ export class ManagedTable extends React.Component<
|
||||
}
|
||||
return this.props.rows
|
||||
.filter((row) => highlightedRows.has(row.key))
|
||||
.map(
|
||||
(row: TableBodyRow) =>
|
||||
row.copyText || this.getTextContentOfRow(row.key).join('\t'),
|
||||
.map((row: TableBodyRow) =>
|
||||
typeof row.copyText === 'function'
|
||||
? row.copyText()
|
||||
: row.copyText || this.getTextContentOfRow(row.key).join('\t'),
|
||||
)
|
||||
.join('\n');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user