Skip to content

Safer and faster shallow handling#343

Merged
hueniverse merged 3 commits intohapijs:masterfrom
kanongil:better-shallow
Jan 3, 2020
Merged

Safer and faster shallow handling#343
hueniverse merged 3 commits intohapijs:masterfrom
kanongil:better-shallow

Conversation

@kanongil
Copy link
Copy Markdown
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
Copy Markdown
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