@@ -918,12 +918,6 @@ module AdaptiveHashSetImplementation =
918918 cache.[ m] <- v
919919 v
920920
921- member x.Invoke2 ( token : AdaptiveToken , m : aval < 'T >) =
922- let o = cache.[ m]
923- let v = m.GetValue token
924- cache.[ m] <- v
925- o, v
926-
927921 member x.Revoke ( m : aval < 'T >, dirty : System.Collections.Generic.HashSet < _ >) =
928922 match cache.TryGetValue m with
929923 | ( true , v) ->
@@ -944,9 +938,14 @@ module AdaptiveHashSetImplementation =
944938 )
945939
946940 for d in dirty do
947- let o , n = x.Invoke2( token, d)
948- if not ( DefaultEquality.equals o n) then
949- deltas <- HashSetDelta.combine deltas ( HashSetDelta.ofList [ Add n; Rem o])
941+ match cache.TryGetValue d with
942+ | ( true , o) ->
943+ let n = d.GetValue token
944+ cache.[ d] <- n
945+ if not ( DefaultEquality.equals o n) then
946+ deltas <- HashSetDelta.combine deltas ( HashSetDelta.ofArray [| Add n; Rem o |])
947+ | _ -> ()
948+
950949
951950 deltas
952951
@@ -970,15 +969,8 @@ module AdaptiveHashSetImplementation =
970969 | _ ->
971970 let r = ref ( 1 , v)
972971 cache.[ m] <- r
973-
974972 v
975973
976- member x.Invoke2 ( token : AdaptiveToken , m : aval < 'B >) =
977- let r = cache.[ m]
978- let v = m.GetValue token
979- let ( rc , o ) = r.Value
980- r.Value <- ( rc, v)
981- o, v
982974
983975 member x.Revoke ( v : 'A , dirty : System.Collections.Generic.HashSet < _ >) =
984976 let m = mapping.Revoke v
@@ -1007,9 +999,15 @@ module AdaptiveHashSetImplementation =
1007999 )
10081000
10091001 for d in dirty do
1010- let o , n = x.Invoke2( token, d)
1011- if not ( DefaultEquality.equals o n) then
1012- deltas <- HashSetDelta.combine deltas ( HashSetDelta.ofList [ Add n; Rem o])
1002+ match cache.TryGetValue d with
1003+ | ( true , r) ->
1004+ let n = d.GetValue token
1005+ let ( rc , o ) = r.Value
1006+ r.Value <- ( rc, n)
1007+ if not ( DefaultEquality.equals o n) then
1008+ deltas <- HashSetDelta.combine deltas ( HashSetDelta.ofArray [| Add n; Rem o |])
1009+ | _ -> ()
1010+
10131011
10141012 deltas
10151013
@@ -1210,7 +1208,7 @@ module ASet =
12101208 else constant ( fun () -> HashSet.union va vb)
12111209 else
12121210 // TODO: can be optimized in case one of the two sets is constant.
1213- ofReader ( fun () -> UnionConstantReader ( HashSet.ofList [ a ; b ]))
1211+ ofReader ( fun () -> UnionConstantReader ( HashSet.ofArray [| a ; b | ]))
12141212
12151213 /// Adaptively subtracts the given sets.
12161214 let difference ( a : aset < 'A >) ( b : aset < 'A >) =
0 commit comments