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(
1717 const llvm::DenseMap<const void *, uint64_t > §ionToIdx) const {
1818 constexpr unsigned windowSize = 4 ;
1919
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);
2527
2628 llvm::sort (hashes);
2729 hashes.erase (std::unique (hashes.begin (), hashes.end ()), hashes.end ());
You can’t perform that action at this time.
0 commit comments