Skip to content

Commit 6c98d22

Browse files
committed
fixed CompactASetExtensions leaking deltas until next update
1 parent 33a7026 commit 6c98d22

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/Aardvark.Rendering/Resources/Adaptive/AdaptiveCompactBuffer.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module internal CompactBufferImplementation =
2525
let count = ASet.count input
2626
let compact = ASet.compact input
2727
let reader = compact.GetReader()
28-
let removals = List()
2928

3029
member inline private x.Transact =
3130
if x.ProcessDeltasInTransaction then transact
@@ -64,6 +63,8 @@ module internal CompactBufferImplementation =
6463
// Process deltas
6564
x.Transact (fun _ ->
6665

66+
let removals = List(ops.Count)
67+
6768
for o in ops do
6869
match o with
6970
| value, Set index ->
@@ -74,8 +75,7 @@ module internal CompactBufferImplementation =
7475

7576
// Process removals after sets to prevent potential reaquiring of resources
7677
for r in removals do
77-
x.Remove r
78-
removals.Clear()
78+
x.Remove r
7979
)
8080

8181
x.Update(t)

src/Aardvark.Rendering/Utilities/CompactSet.fs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ module CompactASetExtensions =
1818
let mutable keys : 'T[] = Array.empty
1919

2020
let reader = input.GetReader()
21-
let added = List()
22-
let removed = List()
23-
let deltas = List<'T * ElementOperation<int>>()
24-
let free = Queue<int>()
2521

2622
AMap.custom (fun token indices ->
27-
added.Clear()
28-
removed.Clear()
29-
deltas.Clear()
30-
3123
let ops = reader.GetChanges token
3224

25+
let added = List(ops.Count)
26+
let removed = List(ops.Count)
27+
3328
for o in ops do
3429
match o with
3530
| Add(_, value) -> value |> added.Add |> ignore
@@ -42,6 +37,9 @@ module CompactASetExtensions =
4237
// If we remove more values than we add, we have to move some elements from the end (potentially all of them).
4338
let moving = HashSet([newCount .. newCount - (delta + 1)])
4439

40+
let free = Queue<int>(removed.Count)
41+
let deltas = List<'T * ElementOperation<int>>(added.Count + removed.Count + moving.Count)
42+
4543
// Remove
4644
for key in removed do
4745
deltas.Add(key, Remove)

0 commit comments

Comments
 (0)