onmyway133 / DeepDiff

🦀Amazingly incredible extraordinary lightning fast diffing in Swift
https://onmyway133.com/apps/
Other
2.05k stars 143 forks source link

Incorrect use of hashValue as a symbolic-table key. #21

Closed ra1028 closed 5 years ago

ra1028 commented 6 years ago

I found this problem when I wrote a comparison in the README of my diffing library DifferenceKit.

As described in the Apple document, it's obviously wrong to use hashValue to identify the elements.

In heckel algorithm, It's necessary to use Hashable compliant object itself for the key of symbolic-table. Since this has a big impact on performance, you should also update the README.

I know that this issue duplicated with https://github.com/onmyway133/DeepDiff/issues/13. Why did you close it?

onmyway133 commented 6 years ago

@ra1028 Hi, first of all, congrats on DifferentKit, seems like a nifty framework 👍

About the use of hashValue, my first thinking was to have a quick way to check if 2 objects are not equal, but it can potentially give room for hash value collision. I think I will update the project according to the suggestions

onmyway133 commented 6 years ago

@ra1028 Currently the hashValue acts like an id, which has potentiality for collisions, I'm thinking about following React to introduce key instead

ValCanBuild commented 5 years ago

@onmyway133 I think this can be closed with the introduction of DiffAware protocol?