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
83
83
in (GlobalKeyValueMap (Map. insert newKey new_index hm) (IM. insert n newKey im) (n+ 1 ), new_index)
84
84
{-# NOINLINE newKey #-}
85
85
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.
86
93
lookupKeyValue :: Key -> KeyValue
87
- lookupKeyValue (UnsafeMkKey x) = unsafePerformIO $ do
94
+ lookupKeyValue (UnsafeMkKey ! x) = unsafePerformIO $ do
88
95
GlobalKeyValueMap _ im _ <- readIORef keyMap
89
96
pure $! im IM. ! x
90
97
You can’t perform that action at this time.
0 commit comments