diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-08-03 20:16:58 +0200 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2015-08-05 10:10:33 +0200 |
commit | 926e4288c5aabb75addcdc4cbdc106e74c11162d (patch) | |
tree | 898f838e1e89996abe999bc90db949b0f06ac18b /compiler/utils/BufWrite.hs | |
parent | 6f6d082124b24bd8437f95d99a8fd8844a0f6cd8 (diff) | |
download | haskell-926e4288c5aabb75addcdc4cbdc106e74c11162d.tar.gz |
Pretty: use BangPatterns instead of manual unboxing Ints (#10735)
Follow same style as libraries/pretty, although some of it is pretty
archaic, and could be improved with BangPatterns:
* `get w _ | w == 0 && False = undefined`
* `mkNest k _ | k `seq` False = undefined`
Diffstat (limited to 'compiler/utils/BufWrite.hs')
-rw-r--r-- | compiler/utils/BufWrite.hs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/utils/BufWrite.hs b/compiler/utils/BufWrite.hs index 40b9759a7b..48a2c4c940 100644 --- a/compiler/utils/BufWrite.hs +++ b/compiler/utils/BufWrite.hs @@ -24,7 +24,6 @@ module BufWrite ( ) where import FastString -import FastTypes import FastMutInt import Control.Monad ( when ) @@ -97,16 +96,15 @@ bPutCStringLen b@(BufHandle buf r hdl) cstr@(ptr, len) = do copyBytes (buf `plusPtr` i) ptr len writeFastMutInt r (i + len) -bPutLitString :: BufHandle -> LitString -> FastInt -> IO () -bPutLitString b@(BufHandle buf r hdl) a len_ = a `seq` do - let len = iBox len_ +bPutLitString :: BufHandle -> LitString -> Int -> IO () +bPutLitString b@(BufHandle buf r hdl) a len = a `seq` do i <- readFastMutInt r if (i+len) >= buf_size then do hPutBuf hdl buf i writeFastMutInt r 0 if (len >= buf_size) then hPutBuf hdl a len - else bPutLitString b a len_ + else bPutLitString b a len else do copyBytes (buf `plusPtr` i) a len writeFastMutInt r (i+len) |