File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,13 @@ void BPSectionELF::getSectionHashes(
17
17
const llvm::DenseMap<const void *, uint64_t > §ionToIdx) const {
18
18
constexpr unsigned windowSize = 4 ;
19
19
20
- size_t size = isec->content ().size ();
21
- for (size_t i = 0 ; i != size; ++i) {
22
- auto window = isec->content ().drop_front (i).take_front (windowSize);
23
- hashes.push_back (xxHash64 (window));
24
- }
20
+ // Calculate content hashes: k-mers and the last k-1 bytes.
21
+ ArrayRef<uint8_t > data = isec->content ();
22
+ if (data.size () >= windowSize)
23
+ for (size_t i = 0 ; i <= data.size () - windowSize; ++i)
24
+ hashes.push_back (llvm::support::endian::read32le (data.data () + i));
25
+ for (uint8_t byte : data.take_back (windowSize - 1 ))
26
+ hashes.push_back (byte);
25
27
26
28
llvm::sort (hashes);
27
29
hashes.erase (std::unique (hashes.begin (), hashes.end ()), hashes.end ());
You can’t perform that action at this time.
0 commit comments