1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Rename the live set functions uniquely.

This commit is contained in:
Rob Rix 2017-12-01 14:33:41 -05:00
parent 67f8aedc50
commit 3652fd2c63
4 changed files with 17 additions and 17 deletions

View File

@ -30,8 +30,8 @@ gc roots store = storeRestrict store (reachable roots store)
reachable :: (Ord (LocationFor a), Foldable (Cell (LocationFor a)), ValueRoots (LocationFor a) a) => Live (LocationFor a) a -> Store (LocationFor a) a -> Live (LocationFor a) a
reachable roots store = go roots mempty
where go set seen = case split set of
where go set seen = case liveSplit set of
Nothing -> seen
Just (a, as)
| Just values <- storeLookupAll a store -> go (difference (foldr ((<>) . valueRoots) mempty values <> as) seen) (insert a seen)
| otherwise -> go seen (insert a seen)
| Just values <- storeLookupAll a store -> go (liveDifference (foldr ((<>) . valueRoots) mempty values <> as) seen) (liveInsert a seen)
| otherwise -> go seen (liveInsert a seen)

View File

@ -20,7 +20,7 @@ envInsert :: Name -> Address l a -> Environment l a -> Environment l a
envInsert name value (Environment m) = Environment (Map.insert name value m)
envRoots :: (Ord l, Foldable t) => Environment l a -> t Name -> Live l a
envRoots env = foldr ((<>) . maybe mempty singleton . flip envLookup env) mempty
envRoots env = foldr ((<>) . maybe mempty liveSingleton . flip envLookup env) mempty
-- Instances

View File

@ -13,23 +13,23 @@ import Unsafe.Coerce
newtype Live l v = Live { unLive :: Set (Address l v) }
deriving (Eq, Foldable, Monoid, Ord, Semigroup, Show)
singleton :: Address l v -> Live l v
singleton = Live . Set.singleton
liveSingleton :: Address l v -> Live l v
liveSingleton = Live . Set.singleton
insert :: Ord l => Address l v -> Live l v -> Live l v
insert addr = Live . Set.insert addr . unLive
liveInsert :: Ord l => Address l v -> Live l v -> Live l v
liveInsert addr = Live . Set.insert addr . unLive
delete :: Ord l => Address l v -> Live l v -> Live l v
delete addr = Live . Set.delete addr . unLive
liveDelete :: Ord l => Address l v -> Live l v -> Live l v
liveDelete addr = Live . Set.delete addr . unLive
difference :: Ord l => Live l v -> Live l v -> Live l v
difference = fmap Live . (Set.difference `on` unLive)
liveDifference :: Ord l => Live l v -> Live l v -> Live l v
liveDifference = fmap Live . (Set.difference `on` unLive)
member :: Ord l => Address l v -> Live l v -> Bool
member addr = Set.member addr . unLive
liveMember :: Ord l => Address l v -> Live l v -> Bool
liveMember addr = Set.member addr . unLive
split :: Ord l => Live l v -> Maybe (Address l v, Live l v)
split = fmap (second Live) . Set.minView . unLive
liveSplit :: Ord l => Live l v -> Maybe (Address l v, Live l v)
liveSplit = fmap (second Live) . Set.minView . unLive
instance Generic1 (Live l) where

View File

@ -36,4 +36,4 @@ storeSize :: Store l a -> Int
storeSize = Map.size . unStore
storeRestrict :: Ord l => Store l a -> Live l a -> Store l a
storeRestrict (Store m) roots = Store (Map.filterWithKey (\ address _ -> Address address `member` roots) m)
storeRestrict (Store m) roots = Store (Map.filterWithKey (\ address _ -> Address address `liveMember` roots) m)