r3labs / diff

A library for diffing golang structures
Mozilla Public License 2.0
888 stars 80 forks source link

Re-worked patch engine. #42

Closed ghost closed 3 years ago

ghost commented 3 years ago

A number of edge cases, bugs and just flat out assumptions caused me to re-think the underlying reflection code and ultimately justified a refactoring.

One of the things I took liberty with, is the information kept in the change log, I've added a copy of an items parent to satisfy the edge case of a target that is complex or a slice and doesn't contain the original 'untouched' items necessary to make the match. I recognize that in complex situations, this could significantly increase the memory footprint of a change log unnecessarily and have added an option to avoid this allocation if the user will not find themselves needing it by default. This caused me to make some rather invasive changes to diff itself which may be unwanted upstream. Im open to critical feedback on this note.

Since it's a refactor, a lot of changes are inside... including:

purehyperbole commented 3 years ago

Hey @kyenos thank you for taking the time to update the diff functionality. At a cursory glance, the changes look really great!

Given the size of the PR and extent of the changes, it may take me a bit of time to properly go through everything (hopefully I can find some time before the end of this this week to go through everything).

purehyperbole commented 3 years ago

Hey @kyenos

The changes look awesome! Only one suggested change (which you also mention in your description).

Once that's in place, I'm happy to merge this.

Thanks again!

purehyperbole commented 3 years ago

Hey @kyenos

Many thanks for updating the PR and again for the contribution. I'll get this merged and cut a release!