Memoizes the functions for getting header both runs and scalar data tables #6836
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for features / changes
Using functions in Angular templates leads to unnecessary recomputation, e.g. getHeaders() is called 60 times from data tables on init and add). More seriously, they also interfere with other component usage like CDK Overlay: namely, when an Overlay is set to appear next to a header, the header element is destroyed and recreated (because of the function in the template) before the Overlay can position itself, and ends up always resetting its position to (0,0). Simply memoizing the function will prevent the recomputation (Angular ref).
Profiling the memoized change (using Chrome devtools profiler, which is admittedly a bit inconsistent) seems to show a several 100ms improvement in scripting performance.
Technical description of changes
Replaces the
getHeaders
functions used in scalar/runs data tables with a new memoizedextendHeaders(headers)
function.No change in UI behavior.
Screenshots of UI changes (or N/A)
N/A