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

Safer and faster shallow handling #343

Merged
merged 3 commits into from
Jan 3, 2020
Merged

Conversation

kanongil
Copy link
Contributor

This patch refactors the shallow handling of clone() and applyToDefaults() to avoid temporarily modifying the source object, and setting properties on the target object multiple times.

The handling is done in a simple and effective manner by pre-filling a seen Map() that is passed to the internal call to clone().

This new handling should also increase the performance of shallow copies.

@hueniverse
Copy link
Contributor

Smart.

The clone() change is a breaking change because if a value is used by more than one key, and you only shallow one, the other one will now also be shallow. This is fine for all my use cases but it is a breaking change.

I need to review the applyToDefaults() change more closely.

@hueniverse hueniverse self-assigned this Oct 17, 2019
@hueniverse hueniverse added breaking changes Change that can breaking existing code feature New functionality or improvement labels Oct 17, 2019
@hueniverse hueniverse added this to the 9.0.0 milestone Jan 3, 2020
@hueniverse hueniverse merged commit 08b1094 into hapijs:master Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Change that can breaking existing code feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants