Git Product home page Git Product logo

Comments (4)

the8472 avatar the8472 commented on August 17, 2024 2

Hash is not a cryptographic hash, so it does not promise a collision probability so low that practically all inputs map to distinct outputs. So if the correctness of your program relies on the absence of collisions then it's your program that's wrong, not Hash.

There may be some quality-of-implementation argument about avoiding collisions for data patterns that are likely to coexist. I'm not sure if it is the case here, I'll have to think about it. And even if it is then there also is the matter of making such a avoidance fast. The current code is optimized for speed.

from rust.

zanieb avatar zanieb commented on August 17, 2024 1

I think that's a fair point, but the current implementation already goes out if its way to create equal hashes for paths like foo/./bar and foo/bar — why is foobar and foo/bar different? It seems like a very surprising collision for a user to encounter.

Thanks for taking a look!

from rust.

the8472 avatar the8472 commented on August 17, 2024 1

I think that's a fair point, but the current implementation already goes out if its way to create equal hashes for paths like foo/./bar and foo/bar — why is foobar and foo/bar different?

The difference is that Hash is a companion for Eq. If things compare equal then they must hash the same because that's what hashmaps rely on. foo/./bar and foo/bar do compare equally because Components normalizes the dot away. Therefore they must hash equally, which is why Hash must spend effort on that.

Things comparing inequal does not require the Hash to be different. Instead it's only a matter of quality-of-implementation whether they produce distinct hashes, not a matter of correctness.

from rust.

zanieb avatar zanieb commented on August 17, 2024

That's a great point, thanks for clarifying. I agree this is not a "correctness" problem, but more of a practical consideration for the hashing algorithm.

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.