From 53fb449b008e9b6aed9877b9d33f4026e454e0f9 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 17 Feb 2022 00:41:36 +0100 Subject: sprinkle some NFData everywhere (also some evaluateNF, leading to slightly less memory usage) --- lib/CheckDir.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/CheckDir.hs') diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs index eeb94a8..1aeb5e3 100644 --- a/lib/CheckDir.hs +++ b/lib/CheckDir.hs @@ -10,6 +10,7 @@ module CheckDir (maximumLintLevel, recursiveCheckDir, DirResult(..), MissingAsset(..), MissingDep(..), resultIsFatal) where import CheckMap (MapResult (..), loadAndLintMap) +import Control.DeepSeq (NFData) import Control.Monad (void) import Control.Monad.Extra (mapMaybeM) import Data.Aeson (ToJSON, (.=)) @@ -38,6 +39,7 @@ import Types (Dep (Local, LocalMap), Hint (Hint), Level (..), hintLevel) import Util (PrettyPrint (prettyprint), ellipsis) + -- based on the startling observation that Data.Map has lower complexity -- for difference than Data.Set, but the same complexity for fromList type Set a = Map a () @@ -54,19 +56,20 @@ data DirResult = DirResult -- ^ all dependencies to things outside this repository , dirresultMissingAssets :: [MissingAsset] -- ^ entrypoints of maps which are referred to but missing - , dirresultGraph :: Dot () - } deriving (Generic) + , dirresultGraph :: Text + } deriving (Generic, NFData) data MissingDep = MissingDep { depFatal :: Maybe Bool , entrypoint :: Text , neededBy :: [FilePath] - } deriving (Generic, ToJSON) + } deriving (Generic, ToJSON, NFData) -- | Missing assets are the same thing as missing dependencies, -- but should not be confused (and also serialise differently -- to json) newtype MissingAsset = MissingAsset MissingDep + deriving (Generic, NFData) -- | given this config, should the result be considered to have failed? resultIsFatal :: LintConfig' -> DirResult -> Bool @@ -105,7 +108,6 @@ instance ToJSON DirResult where . foldr aggregateSameResults [] . M.toList $ dirresultMaps res) - -- unused in the hub, temporarily removed to make the output smaller , "exitGraph" .= showDot (dirresultGraph res) ] , "severity" .= maximumLintLevel res @@ -178,7 +180,9 @@ recursiveCheckDir config prefix root = do , dirresultMissingAssets = mAssets , dirresultMaps = maps' , dirresultGraph = - graphToDot + T.pack + . showDot + . graphToDot . takeSubGraph 7 root $ exitGraph } -- cgit v1.2.3