aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libutil/references.cc14
-rw-r--r--src/libutil/references.hh3
2 files changed, 7 insertions, 10 deletions
diff --git a/src/libutil/references.cc b/src/libutil/references.cc
index 249c78bf7..8792578d4 100644
--- a/src/libutil/references.cc
+++ b/src/libutil/references.cc
@@ -96,15 +96,12 @@ void RewritingSink::operator () (std::string_view data)
auto consumed = s.size() - prev.size();
- pos += consumed;
-
if (consumed) nextSink(s.substr(0, consumed));
}
void RewritingSink::flush()
{
if (prev.empty()) return;
- pos += prev.size();
nextSink(prev);
prev.clear();
}
@@ -112,20 +109,23 @@ void RewritingSink::flush()
HashResult computeHashModulo(HashType ht, const std::string & modulus, Source & source)
{
HashSink hashSink(ht);
+ LengthSink lengthSink;
RewritingSink rewritingSink(modulus, std::string(modulus.size(), 0), hashSink);
- source.drainInto(rewritingSink);
+ TeeSink tee{rewritingSink, lengthSink};
+ source.drainInto(tee);
rewritingSink.flush();
/* Hash the positions of the self-references. This ensures that a
NAR with self-references and a NAR with some of the
self-references already zeroed out do not produce a hash
collision. FIXME: proof. */
- for (auto & pos : rewritingSink.matches)
- hashSink(fmt("|%d", pos));
+ // NOTE(horrors) RewritingSink didn't track any matches!
+ //for (auto & pos : rewritingSource.matches)
+ // hashSink(fmt("|%d", pos));
auto h = hashSink.finish();
- return {h.first, rewritingSink.pos};
+ return {h.first, lengthSink.length};
}
}
diff --git a/src/libutil/references.hh b/src/libutil/references.hh
index 970d2d235..3fefd824b 100644
--- a/src/libutil/references.hh
+++ b/src/libutil/references.hh
@@ -29,9 +29,6 @@ struct RewritingSink : Sink
std::string::size_type maxRewriteSize;
std::string prev;
Sink & nextSink;
- uint64_t pos = 0;
-
- std::vector<uint64_t> matches;
RewritingSink(const std::string & from, const std::string & to, Sink & nextSink);
RewritingSink(const StringMap & rewrites, Sink & nextSink);