diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-30 20:38:43 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-30 20:38:43 +0400 |
commit | 03197ae3eead914726c259f40ff53d275c39e0e2 (patch) | |
tree | a09a28fea267b7b3634df1a4da63e104bf8c2bab /src/System | |
parent | 8ecd0d15e202291324ed4f56ce3f31de420a0bda (diff) |
~ Avoid piece copying in piece validation.
The 'getPiece' is internal function, so no need to copy the all piece.
This optimization removes 5% of overall program allocation.
Diffstat (limited to 'src/System')
-rw-r--r-- | src/System/Torrent/Storage.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/System/Torrent/Storage.hs b/src/System/Torrent/Storage.hs index 8a884196..955c1746 100644 --- a/src/System/Torrent/Storage.hs +++ b/src/System/Torrent/Storage.hs | |||
@@ -172,8 +172,8 @@ getPiece :: PieceIx -> Storage -> IO ByteString | |||
172 | getPiece pix st @ Storage {..} = {-# SCC getPiece #-} do | 172 | getPiece pix st @ Storage {..} = {-# SCC getPiece #-} do |
173 | let pieceLen = pieceLength session | 173 | let pieceLen = pieceLength session |
174 | let bix = BlockIx pix 0 (pieceLength session) | 174 | let bix = BlockIx pix 0 (pieceLength session) |
175 | bs <- readBytes (ixInterval pieceLen bix) payload | 175 | let bs = viewBytes (ixInterval pieceLen bix) payload |
176 | return (Lazy.toStrict bs) | 176 | return $! Lazy.toStrict bs |
177 | 177 | ||
178 | resetPiece :: PieceIx -> Storage -> IO () | 178 | resetPiece :: PieceIx -> Storage -> IO () |
179 | resetPiece pix st @ Storage {..} | 179 | resetPiece pix st @ Storage {..} |