From 5af76dee371ea5fa1eb72141370fdf18851d67c7 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Wed, 1 May 2024 20:10:00 +0200 Subject: libutil: turn HashModuloSink into a free function Change-Id: I5878007502fa68c2816a0f4c61f7d0e60bdde702 --- src/libutil/references.cc | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/libutil/references.cc') diff --git a/src/libutil/references.cc b/src/libutil/references.cc index 6189f69b9..249c78bf7 100644 --- a/src/libutil/references.cc +++ b/src/libutil/references.cc @@ -109,19 +109,12 @@ void RewritingSink::flush() prev.clear(); } -HashModuloSink::HashModuloSink(HashType ht, const std::string & modulus) - : hashSink(ht) - , rewritingSink(modulus, std::string(modulus.size(), 0), hashSink) +HashResult computeHashModulo(HashType ht, const std::string & modulus, Source & source) { -} + HashSink hashSink(ht); + RewritingSink rewritingSink(modulus, std::string(modulus.size(), 0), hashSink); -void HashModuloSink::operator () (std::string_view data) -{ - rewritingSink(data); -} - -HashResult HashModuloSink::finish() -{ + source.drainInto(rewritingSink); rewritingSink.flush(); /* Hash the positions of the self-references. This ensures that a -- cgit v1.2.3