From edd93b41c519ddf32ed34f495f4b9a14828d71a3 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Wed, 27 Jun 2018 20:35:14 -0400 Subject: More performant routeMap (IntMap -> Array). --- examples/dhtd.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/dhtd.hs') diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 3f2a6a63..8e9e7692 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs @@ -27,6 +27,7 @@ import Control.Concurrent.STM.TMChan import Control.Exception import Control.Monad import Control.Monad.IO.Class (liftIO) +import Data.Array.MArray (getAssocs) import Data.Bool import Data.Char import Data.Conduit as C @@ -930,7 +931,7 @@ clientSession s@Session{..} sock cnum h = do ("onion", s) -> cmd0 $ do now <- getPOSIXTime join $ atomically $ do - rm <- readTVar $ routeMap onionRouter + rm <- IntMap.fromList . catMaybes . map (\(i,m) -> fmap (i,) m) <$> getAssocs (routeMap onionRouter) ts <- readTVar $ trampolineNodes onionRouter tcnt <- readTVar $ trampolineCount onionRouter icnt <- HashMap.size <$> readTVar (trampolineIds onionRouter) -- cgit v1.2.3