cache the serialization of a Key

This will speed up the common case where a Key is deserialized from
disk, but is then serialized to build eg, the path to the annex object.

It means that every place a Key has any of its fields changed, the cache
has to be dropped. I've grepped and found them all. But, it would be
better to avoid that gotcha somehow..
This commit is contained in:
Joey Hess 2019-01-14 16:33:20 -04:00
parent 918868915c
commit 4536c93bb2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
9 changed files with 34 additions and 7 deletions

View file

@ -68,7 +68,10 @@ chunkKeyStream :: Key -> ChunkSize -> ChunkKeyStream
chunkKeyStream basek chunksize = ChunkKeyStream $ map mk [1..]
where
mk chunknum = sizedk { keyChunkNum = Just chunknum }
sizedk = basek { keyChunkSize = Just (toInteger chunksize) }
sizedk = basek
{ keyChunkSize = Just (toInteger chunksize)
, keySerialization = Nothing
}
nextChunkKeyStream :: ChunkKeyStream -> (Key, ChunkKeyStream)
nextChunkKeyStream (ChunkKeyStream (k:l)) = (k, ChunkKeyStream l)