on master help sign in
Have Nitpick.Debug just tell if a LocalGraph has any debug uses

This way it is not necessary to look through the entire graph when one is found. If you found one usage, no need to keep looking.

commitc5e2ff5794b085c00455e92bd02b7da8c9c9200b authorEvan Czaplicki <evancz@users.noreply.github.com> dateSun 24 Mar 2019, 15:33 (8 years ago) parent29fbe6b
1 file changed+6−18
compiler/src/Nitpick/Debug.hs+6−18
compiler/src/Nitpick/Debug.hs+6−18
@@ -1,33 +1,21 @@
11module Nitpick.Debug
2− ( findDebugUses
2+ ( hasDebugUses
33 )
44 where
55
66
7−import qualified Data.Map as Map
8−import qualified Data.Name as Name
9−import qualified Data.Set as Set
7+import qualified Data.Map.Utils as Map
108
119import qualified AST.Optimized as Opt
12−import qualified Elm.ModuleName as ModuleName
13−import qualified Elm.Package as Pkg
1410
1511
1612
17−-- FIND DEBUG USES
13+-- HAS DEBUG USES
1814
1915
20−findDebugUses :: Pkg.Name -> Opt.Graph -> [Name.Name]
21−findDebugUses pkg (Opt.Graph _ graph _) =
22− Set.toList $ Map.foldrWithKey (addDebugUses pkg) Set.empty graph
23−
24−
25−addDebugUses :: Pkg.Name -> Opt.Global -> Opt.Node -> Set.Set Name.Name -> Set.Set Name.Name
26−addDebugUses here (Opt.Global (ModuleName.Canonical pkg home) _) node uses =
27− if pkg == here && nodeHasDebug node then
28− Set.insert home uses
29− else
30− uses
16+hasDebugUses :: Opt.LocalGraph -> Bool
17+hasDebugUses (Opt.LocalGraph _ graph _) =
18+ Map.any nodeHasDebug graph
3119
3220
3321nodeHasDebug :: Opt.Node -> Bool