File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
hls-graph/src/Development/IDE/Graph/Internal Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -83,8 +83,15 @@ newKey k = unsafePerformIO $ do
8383 in (GlobalKeyValueMap (Map. insert newKey new_index hm) (IM. insert n newKey im) (n+ 1 ), new_index)
8484{-# NOINLINE newKey #-}
8585
86+ -- NOTE:
87+ -- The argument to this function has a bang pattern. This bang pattern is a load
88+ -- bearing bang pattern. The reason is that the x, if not forced yet, is a thunk
89+ -- that forces the atomicModifyIORef' in the creation of the new key. If it
90+ -- isn't forced *before* reading the keyMap, the keyMap will only obtain the new
91+ -- key (x) *after* the IntMap is already copied out of the keyMap reference,
92+ -- i.e. when it is forced for the lookup in the IntMap.
8693lookupKeyValue :: Key -> KeyValue
87- lookupKeyValue (UnsafeMkKey x) = unsafePerformIO $ do
94+ lookupKeyValue (UnsafeMkKey ! x) = unsafePerformIO $ do
8895 GlobalKeyValueMap _ im _ <- readIORef keyMap
8996 pure $! im IM. ! x
9097
You can’t perform that action at this time.
0 commit comments