Skip to content

Commit 60fb24f

Browse files
committed
[fix] don't store thunk for shown key when the Show dict is in the existential anyway
1 parent 8cac5fb commit 60fb24f

File tree

1 file changed

+7
-7
lines changed
  • hls-graph/src/Development/IDE/Graph/Internal

1 file changed

+7
-7
lines changed

hls-graph/src/Development/IDE/Graph/Internal/Key.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ import System.IO.Unsafe
5252
newtype Key = UnsafeMkKey Int
5353

5454
pattern Key :: () => (Typeable a, Hashable a, Show a) => a -> Key
55-
pattern Key a <- (lookupKeyValue -> KeyValue a _)
55+
pattern Key a <- (lookupKeyValue -> KeyValue a)
5656
{-# COMPLETE Key #-}
5757

58-
data KeyValue = forall a . (Typeable a, Hashable a, Show a) => KeyValue a Text
58+
data KeyValue = forall a . (Typeable a, Hashable a, Show a) => KeyValue a
5959

6060
instance Eq KeyValue where
61-
KeyValue a _ == KeyValue b _ = Just a == cast b
61+
KeyValue a == KeyValue b = Just a == cast b
6262
instance Hashable KeyValue where
63-
hashWithSalt i (KeyValue x _) = hashWithSalt i (typeOf x, x)
63+
hashWithSalt i (KeyValue x) = hashWithSalt i (typeOf x, x)
6464
instance Show KeyValue where
65-
show (KeyValue _ t) = T.unpack t
65+
show (KeyValue k) = show k
6666

6767
data GlobalKeyValueMap = GlobalKeyValueMap !(Map.HashMap KeyValue Key) !(IntMap KeyValue) {-# UNPACK #-} !Int
6868

@@ -73,7 +73,7 @@ keyMap = unsafePerformIO $ newIORef (GlobalKeyValueMap Map.empty IM.empty 0)
7373

7474
newKey :: (Typeable a, Hashable a, Show a) => a -> Key
7575
newKey k = unsafePerformIO $ do
76-
let !newKey = KeyValue k (T.pack (show k))
76+
let !newKey = KeyValue k
7777
atomicModifyIORef' keyMap $ \km@(GlobalKeyValueMap hm im n) ->
7878
let new_key = Map.lookup newKey hm
7979
in case new_key of
@@ -98,7 +98,7 @@ instance Show Key where
9898
show (Key x) = show x
9999

100100
renderKey :: Key -> Text
101-
renderKey (lookupKeyValue -> KeyValue _ t) = t
101+
renderKey (lookupKeyValue -> KeyValue k) = T.pack (show k)
102102

103103
newtype KeySet = KeySet IntSet
104104
deriving newtype (Eq, Ord, Semigroup, Monoid, NFData)

0 commit comments

Comments
 (0)