refactor(app): hoist getLabwareDefsFromCommands outside of each protocol command text #16478
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.
Overview
After #16451, it seemed like a good idea to do an audit of our O(n)
getLabwareDefinitionsFromCommands
util to see if we could improve performance elsewhere in the app. Turns out, pretty much every place that it's used has room for improvement (mainly in the case handled by this PR and in LPC flows).One such place is within each protocol command text. When we display a list of protocol command texts, for every protocol step associated with a
labwareId
, we iterate over the entirety of protocol analysis. This PR acts as a half-measure: hoist out the util far enough to reduce most of the negative performance implications.While we could go farther and really clean this up, I think this is a happy-medium for now. Here is a sustaining ticket for addressing this problem more permanently.
The actual file of interest is
app/src/molecules/Command/utils/getLabwareDisplayLocation.ts
. Everything else is really just refactoring around that hoisting.Test Plan and Hands on Testing
Risk assessment
lowish-medium - We're pretty well covered by
tsc
checks.