Skip to content

Improve vector diffing #15

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

pkoivisto
Copy link

This PR aims to primarily fix the following incorrect output reported by diff-vecs:

       (let [obj1 {"foo" []}
             obj2 {"foo" ["bar" "baz"]}
             patches [{"op" "add" "path" "/foo/0" "value" "bar"}
                      {"op" "add" "path" "/foo/1" "value" "baz"}]]
         (fact "Adding two Array Elements"
               (diff obj1 obj2) => patches))
=> 

FAIL JSON diff - Adding two Array Elements at (core_test.clj:33)
Expected:
[{"op" "add" "path" "/foo/0" "value" "bar"}
 {"op" "add" "path" "/foo/1" "value" "baz"}]
Actual:
[{"op" "replace" "path" "/foo/0" "value" "bar"}
 {"op" "add" "path" "/foo/1" "value" "baz"}]

Additionally, the diff-vecs implementation is slightly changed to improve performance for the likely common case of diff'ed vectors being the same or sharing common prefixes / suffixes.

If any changes to this PR are desired, please feel free to suggest them or just pick from this PR whatever changes you deem desirable.

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.

1 participant