summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2011-08-07 20:12:06 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2011-08-07 20:12:06 -0500
commitbc63eed255188cb2fecaa9e38e8a9e22a34ccf3b (patch)
treeb0fde09d31ec89dfc01d7ae973b25293da713faa
parent1766b98913abc58eb5145a4e22af1e2ba4b2255f (diff)
putLazyBystring cleaner than mapM putWord8
-rw-r--r--lib/OpenPGP.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/OpenPGP.hs b/lib/OpenPGP.hs
index a1e6072..6a161a7 100644
--- a/lib/OpenPGP.hs
+++ b/lib/OpenPGP.hs
@@ -10,6 +10,7 @@ import qualified Data.ByteString.Lazy.UTF8 as LZ (toString, fromString)
10 10
11import Data.Binary 11import Data.Binary
12import Data.Binary.Get 12import Data.Binary.Get
13import Data.Binary.Put
13import qualified Codec.Compression.Zlib.Raw as Zip 14import qualified Codec.Compression.Zlib.Raw as Zip
14import qualified Codec.Compression.Zlib as Zlib 15import qualified Codec.Compression.Zlib as Zlib
15import qualified Codec.Compression.BZip as BZip2 16import qualified Codec.Compression.BZip as BZip2
@@ -76,7 +77,7 @@ instance Binary Packet where
76 -- Use 5-octet lengths 77 -- Use 5-octet lengths
77 put (255 :: Word8) 78 put (255 :: Word8)
78 put ((fromIntegral $ LZ.length body) :: Word32) 79 put ((fromIntegral $ LZ.length body) :: Word32)
79 mapM_ putWord8 (LZ.unpack body) 80 putLazyByteString body
80 where (body, tag) = put_packet p 81 where (body, tag) = put_packet p
81 get = do 82 get = do
82 tag <- get :: Get Word8 83 tag <- get :: Get Word8
@@ -410,7 +411,7 @@ instance Binary MPI where
410 put (((fromIntegral . LZ.length $ bytes) - 1) * 8 411 put (((fromIntegral . LZ.length $ bytes) - 1) * 8
411 + floor (logBase 2 $ fromIntegral (bytes `LZ.index` 0)) 412 + floor (logBase 2 $ fromIntegral (bytes `LZ.index` 0))
412 + 1 :: Word16) 413 + 1 :: Word16)
413 mapM_ putWord8 (LZ.unpack bytes) 414 putLazyByteString bytes
414 where bytes = LZ.unfoldr (\x -> if x == 0 then Nothing 415 where bytes = LZ.unfoldr (\x -> if x == 0 then Nothing
415 else Just (fromIntegral x, x `shiftR` 8)) i 416 else Just (fromIntegral x, x `shiftR` 8)) i
416 get = do 417 get = do
@@ -430,7 +431,7 @@ instance Binary SignatureSubpacket where
430 put (255 :: Word8) 431 put (255 :: Word8)
431 put ((fromIntegral $ LZ.length body) + 1 :: Word32) 432 put ((fromIntegral $ LZ.length body) + 1 :: Word32)
432 put tag 433 put tag
433 mapM_ putWord8 (LZ.unpack body) 434 putLazyByteString body
434 where (body, tag) = put_signature_subpacket p 435 where (body, tag) = put_signature_subpacket p
435 get = do 436 get = do
436 len <- fmap fromIntegral (get :: Get Word8) 437 len <- fmap fromIntegral (get :: Get Word8)