File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ module internal CompactBufferImplementation =
25
25
let count = ASet.count input
26
26
let compact = ASet.compact input
27
27
let reader = compact.GetReader()
28
- let removals = List()
29
28
30
29
member inline private x.Transact =
31
30
if x.ProcessDeltasInTransaction then transact
@@ -64,6 +63,8 @@ module internal CompactBufferImplementation =
64
63
// Process deltas
65
64
x.Transact ( fun _ ->
66
65
66
+ let removals = List( ops.Count)
67
+
67
68
for o in ops do
68
69
match o with
69
70
| value, Set index ->
@@ -74,8 +75,7 @@ module internal CompactBufferImplementation =
74
75
75
76
// Process removals after sets to prevent potential reaquiring of resources
76
77
for r in removals do
77
- x.Remove r
78
- removals.Clear()
78
+ x.Remove r
79
79
)
80
80
81
81
x.Update( t)
Original file line number Diff line number Diff line change @@ -18,18 +18,13 @@ module CompactASetExtensions =
18
18
let mutable keys : 'T [] = Array.empty
19
19
20
20
let reader = input.GetReader()
21
- let added = List()
22
- let removed = List()
23
- let deltas = List< 'T * ElementOperation< int>>()
24
- let free = Queue< int>()
25
21
26
22
AMap.custom ( fun token indices ->
27
- added.Clear()
28
- removed.Clear()
29
- deltas.Clear()
30
-
31
23
let ops = reader.GetChanges token
32
24
25
+ let added = List( ops.Count)
26
+ let removed = List( ops.Count)
27
+
33
28
for o in ops do
34
29
match o with
35
30
| Add(_, value) -> value |> added.Add |> ignore
@@ -42,6 +37,9 @@ module CompactASetExtensions =
42
37
// If we remove more values than we add, we have to move some elements from the end (potentially all of them).
43
38
let moving = HashSet([ newCount .. newCount - ( delta + 1 )])
44
39
40
+ let free = Queue< int>( removed.Count)
41
+ let deltas = List< 'T * ElementOperation< int>>( added.Count + removed.Count + moving.Count)
42
+
45
43
// Remove
46
44
for key in removed do
47
45
deltas.Add( key, Remove)
You can’t perform that action at this time.
0 commit comments