diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2011-12-15 16:19:53 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2011-12-15 16:19:53 +0000 |
commit | 5a1b9ed0aa3a0c240b667dbe504b61b2b68e4d16 (patch) | |
tree | c55e8148f4aca9cc12294b33bdd052ae3934a71b /src/libutil/hash.hh | |
parent | a67b8ae22450a0fe10698042b452f5f2f322e008 (diff) | |
download | guix-5a1b9ed0aa3a0c240b667dbe504b61b2b68e4d16.tar.gz |
* 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.hh | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index cbdcf4c8d4..e0b6478cc4 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(); }; |