diff options
author | Will Thompson <will@willthompson.co.uk> | 2019-01-14 10:15:13 +0000 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2019-01-14 10:16:07 +0000 |
commit | 15b69a01080da2ce913d2b11d9bcc1023ab037ea (patch) | |
tree | ec7f69d15b83d8474a4e740f8772f546fd3f9799 | |
parent | 92d2b2930f9d8c70c6e1548d9bdffe18717ad882 (diff) |
Renderer: build fake names more quietlybetter-filter
This is expected, not an error. We can also just track the next
available fake name, rather than scanning the map each time.
-rw-r--r-- | Bustle/Renderer.hs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/Bustle/Renderer.hs b/Bustle/Renderer.hs index 80e7b08..80374bd 100644 --- a/Bustle/Renderer.hs +++ b/Bustle/Renderer.hs @@ -59,10 +59,6 @@ data Bus = SessionBus | SystemBus deriving (Show, Eq, Ord) -describeBus :: Bus -> String -describeBus SessionBus = "session" -describeBus SystemBus = "system" - -- We keep the column in the map to allow the Monoid instance to preserve the -- ordering returned by sessionParticipants, which is the only view on this -- type exported. @@ -244,6 +240,7 @@ data BusState = , columnsInUse :: Set Double , pending :: Pending , bsFilter :: NameFilter + , nextFakeName :: Integer } data RendererState = @@ -264,6 +261,7 @@ initialBusState ignore x = , columnsInUse = Set.empty , pending = Map.empty , bsFilter = ignore + , nextFakeName = 0 } initialSessionBusState, initialSystemBusState :: NameFilter -> BusState @@ -359,18 +357,12 @@ lookupOtherName bus o = do case filter (Set.member o . aiCurrentNames . snd) (Map.assocs as) of [details] -> return details - -- No matches indicates a corrupt log, which we try to recover from … + -- No known owner for the well-known name. This happens in many cases, + -- especially when a method call causes service activation. [] -> do - warn $ concat [ "'" - , unOtherName o - , "' appeared unheralded on the " - , describeBus bus - , " bus; making something up..." - ] - let namesInUse = Map.keys as - candidates = map (fakeUniqueName . show) - ([1..] :: [Integer]) - u = head $ filter (not . (`elem` namesInUse)) candidates + n <- getsBusState nextFakeName bus + modifyBusState bus $ \bs -> bs { nextFakeName = n + 1 } + let u = fakeUniqueName (show n) addUnique bus u addOther bus o u ai <- lookupUniqueName bus u |