Skip to content

Commit 34c6b1b

Browse files
authored
Merge pull request #1091 from kerams/fff
Refactor EnumerationMode
2 parents 33ad120 + e4b669e commit 34c6b1b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/Fabulous/WidgetDiff.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ type ScalarAttributeComparison =
1111

1212
[<Struct; IsByRefLike; RequireQualifiedAccess; NoComparison; NoEquality>]
1313
type EnumerationMode<'a> =
14-
| AllAddedOrRemoved of struct ('a[] * bool)
14+
| AllAddedOrRemoved of prev: 'a[] * bool // the first element is either prev or next depending on the bool, but using prev as the label allows the compiler to reuse struct fields between cases
1515
| Empty
16-
| ActualDiff of prevNext: struct ('a[] * 'a[])
16+
| ActualDiff of prev: 'a[] * next: 'a[]
1717

1818
module EnumerationMode =
1919
let fromOptions prev next =
@@ -314,7 +314,7 @@ and [<Struct; IsByRefLike>] WidgetChangesEnumerator
314314
member e.MoveNext() =
315315
match mode with
316316
| EnumerationMode.Empty -> false
317-
| EnumerationMode.AllAddedOrRemoved(struct (values, added)) ->
317+
| EnumerationMode.AllAddedOrRemoved(values, added) ->
318318
// use prevIndex regardless if it is for adding or removal
319319
let i = e.prevIndex
320320

@@ -331,7 +331,7 @@ and [<Struct; IsByRefLike>] WidgetChangesEnumerator
331331
else
332332
false
333333

334-
| EnumerationMode.ActualDiff(struct (prev, next)) ->
334+
| EnumerationMode.ActualDiff(prev, next) ->
335335
let mutable prevIndex = e.prevIndex
336336
let mutable nextIndex = e.nextIndex
337337

@@ -431,7 +431,7 @@ and [<Struct; IsByRefLike>] WidgetCollectionChangesEnumerator
431431
member e.MoveNext() =
432432
match mode with
433433
| EnumerationMode.Empty -> false
434-
| EnumerationMode.AllAddedOrRemoved(struct (values, added)) ->
434+
| EnumerationMode.AllAddedOrRemoved(values, added) ->
435435
// use prevIndex regardless if it is for adding or removal
436436
let i = e.prevIndex
437437

@@ -448,7 +448,7 @@ and [<Struct; IsByRefLike>] WidgetCollectionChangesEnumerator
448448
else
449449
false
450450

451-
| EnumerationMode.ActualDiff(struct (prev, next)) ->
451+
| EnumerationMode.ActualDiff(prev, next) ->
452452
let mutable prevIndex = e.prevIndex
453453
let mutable nextIndex = e.nextIndex
454454

0 commit comments

Comments
 (0)