Skip to content

Commit

Permalink
using value option/tuple in ASet BindReader
Browse files Browse the repository at this point in the history
  • Loading branch information
luithefirst committed Sep 25, 2024
1 parent d6be34b commit 6175b5f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/FSharp.Data.Adaptive/AdaptiveHashSet/AdaptiveHashSet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ module AdaptiveHashSetImplementation =
inherit AbstractReader<HashSetDelta<'B>>(HashSetDelta.empty)

let mutable valChanged = 0
let mutable cache : option<'A * IHashSetReader<'B>> = None
let mutable cache : voption<struct('A * IHashSetReader<'B>)> = ValueNone

override x.InputChangedObject(_, i) =
// check if input is different object
Expand All @@ -906,23 +906,23 @@ module AdaptiveHashSetImplementation =
#endif

match cache with
| Some(oldValue, oldReader) when valChanged && not (cheapEqual oldValue newValue) ->
| ValueSome(oldValue, oldReader) when valChanged && not (cheapEqual oldValue newValue) ->
// input changed
let rem = CountingHashSet.removeAll oldReader.State
oldReader.Outputs.Remove x |> ignore
let newReader = (mapping newValue).GetReader()
let add = newReader.GetChanges token
cache <- Some(newValue, newReader)
cache <- ValueSome(newValue, newReader)
HashSetDelta.combine rem add

| Some(_, ro) ->
| ValueSome(_, ro) ->
// input unchanged
ro.GetChanges token

| None ->
| ValueNone ->
// initial
let r = (mapping newValue).GetReader()
cache <- Some(newValue, r)
cache <- ValueSome(newValue, r)
r.GetChanges token

/// Reader for flattenA
Expand Down

0 comments on commit 6175b5f

Please sign in to comment.