Skip to content

[fix]: minor storage lifetime optimization #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

jamieQ
Copy link
Contributor

@jamieQ jamieQ commented Jan 16, 2023

Issue

  • to support the mapRendering & mapOutput API, AnyWorkflow internally stores these transformations in a storage type
  • the existing method implementations would retain the existing storage object unnecessarily, when only the existing transform need be retained

Description

  • removed the unnecessary captures of the full internal storage object when mapping outputs/renderings

Checklist

  • Unit Tests (existing tests suffice)
  • UI Tests n/a
  • Snapshot Tests (iOS only) n/a
  • I have made corresponding changes to the documentation n/a

outputTransform: { transform(self.outputTransform($0)) }
outputTransform: { [outputTransform] in
transform(outputTransform($0))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the common use case, you have things like:

MyWorkflow()
  .asAnyWorkflow()  // creates internal storage
  .mapOutput { ... }  // creates new internal storage & would previously hold a reference to old storage
  .rendered(...)

now we won't keep the storage instances around longer than necessary.

@jamieQ jamieQ marked this pull request as ready for review January 17, 2023 15:54
@jamieQ jamieQ requested a review from a team as a code owner January 17, 2023 15:54
Copy link
Contributor

@square-tomb square-tomb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

@jamieQ jamieQ merged commit 75c2d8f into main Jan 17, 2023
@jamieQ jamieQ deleted the jquadri/fix-storage-captures branch January 17, 2023 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants