Skip to content
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

chore(reducers): reduce object copying in iterators #638

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Nov 15, 2022

aws/aws-sdk-js-v3#4151

  • reduce object copying in iterators

This reducer style makes pointless object copies via { ...acc}:

.reduce((acc, [key, val]) => ({ ...acc, [key]: val }), {});

We know that removing these copies will have no side-effects because the initial accumulator value is {}, and not an external object that should not be mutated.

New pattern:

.reduce((acc, [key, val]) => (acc[key] = val, acc), {});

@kuhe kuhe merged commit e12fe69 into smithy-lang:main Nov 16, 2022
@kuhe kuhe deleted the chore/reducers branch November 16, 2022 17:33
milesziemer pushed a commit to milesziemer/smithy-typescript that referenced this pull request Dec 14, 2022
srchase pushed a commit to srchase/smithy-typescript that referenced this pull request Mar 17, 2023
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