This is an archive of the discontinued LLVM Phabricator instance.

Add convenient functions to compute hashes of byte vectors.
ClosedPublic

Authored by ruiu on Nov 22 2016, 1:11 PM.

Details

Summary

In many sitautions, you just want to compute a hash for one chunk
of data. This patch adds convenient functions for that purpose.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu updated this revision to Diff 78930.Nov 22 2016, 1:11 PM
ruiu retitled this revision from to Add convenient functions to compute hashes of byte vectors..
ruiu updated this object.
ruiu added a reviewer: mehdi_amini.
ruiu added a subscriber: llvm-commits.
davide added a subscriber: davide.Nov 22 2016, 1:15 PM

The code looks correct, but, out of curiosity, where do you plan to use it?

mehdi_amini edited edge metadata.Nov 22 2016, 1:48 PM

That looks fine, but maybe having one of the unittests using the new API would be nice as well?

ruiu added a comment.Nov 22 2016, 2:24 PM

I'm planning to use that in LLD, but it should be useful for other purposes.

ruiu updated this revision to Diff 78949.Nov 22 2016, 2:25 PM
ruiu edited edge metadata.
  • Changed the type from std::vector<uint8_t> to SmallVector<uint8_t, 16 or 20>.
  • Added tests.
davide accepted this revision.Nov 22 2016, 2:26 PM
davide added a reviewer: davide.
This revision is now accepted and ready to land.Nov 22 2016, 2:26 PM
mehdi_amini accepted this revision.Nov 22 2016, 4:38 PM
mehdi_amini edited edge metadata.

LGTM.

I was wondering if instead of returning SmallVector<uint8_t, 20> we could use std::array<uint8_t, 20>?

ruiu added a comment.Nov 22 2016, 4:42 PM

I chose that because of my familiarity with SmallVector compared to std::array. But I agree that probably std::array is better.

ruiu updated this revision to Diff 78991.Nov 22 2016, 4:52 PM
ruiu edited edge metadata.
  • use std::array instead of SmallVector since the size will never change

Great, thanks!
(Still LGTM of course).

This revision was automatically updated to reflect the committed changes.