[Git][ghc/ghc][wip/T17949] 2 commits: T17949 use when instead of if + return()
Daneel S. Yaitskov
gitlab at gitlab.haskell.org
Fri Jun 5 17:06:30 UTC 2020
Daneel S. Yaitskov pushed to branch wip/T17949 at Glasgow Haskell Compiler / GHC
Commits:
6f6d3d52 by Daneel Yaitskov at 2020-06-05T09:58:28-07:00
T17949 use when instead of if + return()
- - - - -
562f75c0 by Daneel Yaitskov at 2020-06-05T10:06:15-07:00
T17949 double check traceEvent and traceMarker
- - - - -
1 changed file:
- libraries/base/Debug/Trace.hs
Changes:
=====================================
libraries/base/Debug/Trace.hs
=====================================
@@ -48,7 +48,7 @@ module Debug.Trace (
import System.IO.Unsafe
-import Control.Monad ((<$!>))
+import Control.Monad ((<$!>), when)
import Foreign.C.String
import GHC.Base
import qualified GHC.Foreign
@@ -266,9 +266,14 @@ traceStack str expr = unsafePerformIO $ do
--
-- @since 4.5.0.0
traceEvent :: String -> a -> a
-traceEvent msg expr = unsafeDupablePerformIO $ do
- traceEventIO msg
- return expr
+traceEvent msg expr =
+ if userTracingEnabled
+ then
+ unsafeDupablePerformIO $ do
+ traceEventIO msg
+ return expr
+ else
+ expr
-- | The 'traceEventIO' function emits a message to the eventlog, if eventlog
-- profiling is available and enabled at runtime.
@@ -279,10 +284,10 @@ traceEvent msg expr = unsafeDupablePerformIO $ do
-- @since 4.5.0.0
traceEventIO :: String -> IO ()
traceEventIO msg =
- if userTracingEnabled
- then GHC.Foreign.withCString utf8 msg $ \(Ptr p) -> IO $ \s ->
- case traceEvent# p s of s' -> (# s', () #)
- else return ()
+ when userTracingEnabled
+ (GHC.Foreign.withCString utf8 msg $ \(Ptr p) -> IO $ \s ->
+ case traceEvent# p s of s' -> (# s', () #))
+
-- $markers
--
@@ -318,9 +323,14 @@ traceEventIO msg =
--
-- @since 4.7.0.0
traceMarker :: String -> a -> a
-traceMarker msg expr = unsafeDupablePerformIO $ do
- traceMarkerIO msg
- return expr
+traceMarker msg expr =
+ if userTracingEnabled
+ then
+ unsafeDupablePerformIO $ do
+ traceMarkerIO msg
+ return expr
+ else
+ expr
-- | The 'traceMarkerIO' function emits a marker to the eventlog, if eventlog
-- profiling is available and enabled at runtime.
@@ -331,7 +341,6 @@ traceMarker msg expr = unsafeDupablePerformIO $ do
-- @since 4.7.0.0
traceMarkerIO :: String -> IO ()
traceMarkerIO msg =
- if userTracingEnabled
- then GHC.Foreign.withCString utf8 msg $ \(Ptr p) -> IO $ \s ->
- case traceMarker# p s of s' -> (# s', () #)
- else return ()
+ when userTracingEnabled
+ (GHC.Foreign.withCString utf8 msg $ \(Ptr p) -> IO $ \s ->
+ case traceMarker# p s of s' -> (# s', () #))
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7d009e39607862462205449a68744a23a66f73d...562f75c0ac60145574e31dc141de555b6ee6f100
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7d009e39607862462205449a68744a23a66f73d...562f75c0ac60145574e31dc141de555b6ee6f100
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200605/10abd280/attachment-0001.html>
More information about the ghc-commits
mailing list