aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/hash.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-12-15 16:19:53 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-12-15 16:19:53 +0000
commit5a1b9ed0aa3a0c240b667dbe504b61b2b68e4d16 (patch)
treec55e8148f4aca9cc12294b33bdd052ae3934a71b /src/libutil/hash.hh
parenta67b8ae22450a0fe10698042b452f5f2f322e008 (diff)
* Refactoring: move sink/source buffering into separate classes.
* Buffer the HashSink. This speeds up hashing a bit because it prevents lots of calls to the hash update functions (e.g. nix-hash went from 9.3s to 8.7s of user time on the closure of my /var/run/current-system).
Diffstat (limited to 'src/libutil/hash.hh')
-rw-r--r--src/libutil/hash.hh5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh
index cbdcf4c8d..e0b6478cc 100644
--- a/src/libutil/hash.hh
+++ b/src/libutil/hash.hh
@@ -91,7 +91,7 @@ string printHashType(HashType ht);
union Ctx;
-class HashSink : public Sink
+class HashSink : public BufferedSink
{
private:
HashType ht;
@@ -102,8 +102,9 @@ public:
HashSink(HashType ht);
HashSink(const HashSink & h);
~HashSink();
- virtual void operator () (const unsigned char * data, unsigned int len);
+ void write(const unsigned char * data, size_t len);
HashResult finish();
+ HashResult currentHash();
};