Skip to content

Simplify chaining of transforms#22994

Merged
RyanCavanaugh merged 2 commits into
masterfrom
chain
Apr 25, 2019
Merged

Simplify chaining of transforms#22994
RyanCavanaugh merged 2 commits into
masterfrom
chain

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 29, 2018

The function is used in one place and only ever called variadically, so it's really just a for-loop with a map ahead of time to fill in context.

@ghost ghost requested a review from rbuckton March 29, 2018 18:44

// Chain together and initialize each transformer.
const transformation = chain(...transformers)(context);
const transformersWithContext = transformers.map(t => t(context));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you verify the performance of this change against a large project? The original version was written so that the final transformation of a file would basically be a function like x => d(c(b(a(x)))) for simple cases rather than relying on array iteration. If anything, I would have been tempted to expand compose and chain to ensure a simple compiled function for a larger number of inputs before falling back to array iteration. To be honest though, since we don't use it heavily the performance characteristics of this approach may be negligible unless you have a large project with a lot of small files.

@typescript-bot
Copy link
Copy Markdown
Collaborator

Thanks for your contribution. This PR has not been updated in a while and cannot be automatically merged at the time being. For housekeeping purposes we are closing stale PRs. If you'd still like to continue working on this PR, please leave a message and one of the maintainers can reopen it.

@ghost ghost reopened this Nov 14, 2018
@ghost ghost assigned rbuckton Nov 16, 2018
@RyanCavanaugh RyanCavanaugh merged commit e007ccf into master Apr 25, 2019
@RyanCavanaugh RyanCavanaugh deleted the chain branch April 25, 2019 17:38
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants