@@ -7,7 +7,7 @@ open Fabulous.StackAllocatedCollections
77open Fabulous.StackAllocatedCollections .StackList
88open Microsoft.FSharp .Core
99
10- type AttributesBundle = ( struct ( StackList< ScalarAttribute> * WidgetAttribute[] voption * WidgetCollectionAttribute[] voption * EnvironmentAttribute[] voption ))
10+ type AttributesBundle = ( struct ( StackList< ScalarAttribute> * WidgetAttribute[] * WidgetCollectionAttribute[] * EnvironmentAttribute[]))
1111
1212[<Struct; NoComparison; NoEquality>]
1313type WidgetBuilder < 'msg , 'marker when 'msg: equality > =
@@ -17,25 +17,25 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =
1717
1818 new ( key: WidgetKey) =
1919 { Key = key
20- Attributes = AttributesBundle( StackList.empty(), ValueNone , ValueNone , ValueNone ) }
20+ Attributes = AttributesBundle( StackList.empty(), [||], [||], [||] ) }
2121
2222 new ( key: WidgetKey, attributes: AttributesBundle) = { Key = key; Attributes = attributes }
2323
2424 new ( key: WidgetKey, scalar: ScalarAttribute) =
2525 { Key = key
26- Attributes = AttributesBundle( StackList.one scalar, ValueNone , ValueNone , ValueNone ) }
26+ Attributes = AttributesBundle( StackList.one scalar, [||], [||], [||] ) }
2727
2828 new ( key: WidgetKey, scalarA: ScalarAttribute, scalarB: ScalarAttribute) =
2929 { Key = key
30- Attributes = AttributesBundle( StackList.two( scalarA, scalarB), ValueNone , ValueNone , ValueNone ) }
30+ Attributes = AttributesBundle( StackList.two( scalarA, scalarB), [||], [||], [||] ) }
3131
3232 new ( key: WidgetKey, scalar1: ScalarAttribute, scalar2: ScalarAttribute, scalar3: ScalarAttribute) =
3333 { Key = key
34- Attributes = AttributesBundle( StackList.three( scalar1, scalar2, scalar3), ValueNone , ValueNone , ValueNone ) }
34+ Attributes = AttributesBundle( StackList.three( scalar1, scalar2, scalar3), [||], [||], [||] ) }
3535
3636 new ( key: WidgetKey, widget: WidgetAttribute) =
3737 { Key = key
38- Attributes = AttributesBundle( StackList.empty(), ValueSome [| widget |], ValueNone , ValueNone ) }
38+ Attributes = AttributesBundle( StackList.empty(), [| widget |], [||], [||] ) }
3939
4040 [<EditorBrowsable( EditorBrowsableState.Never) >]
4141 member x.Compile () : Widget =
@@ -48,14 +48,23 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =
4848#endif
4949 ScalarAttributes =
5050 match StackList.length & scalarAttributes with
51- | 0 us -> ValueNone
52- | _ -> ValueSome ( Array.sortInPlace _. Key ( StackList.toArray & scalarAttributes) )
51+ | 0 us -> [||]
52+ | _ -> Array.sortInPlace _. Key ( StackList.toArray & scalarAttributes)
5353
54- WidgetAttributes = ValueOption.map ( Array.sortInPlace(_. Key)) widgetAttributes
54+ WidgetAttributes =
55+ match widgetAttributes with
56+ | [||] -> [||]
57+ | _ -> Array.sortInPlace _. Key widgetAttributes
5558
56- WidgetCollectionAttributes = widgetCollectionAttributes |> ValueOption.map( Array.sortInPlace(_. Key))
59+ WidgetCollectionAttributes =
60+ match widgetCollectionAttributes with
61+ | [||] -> [||]
62+ | _ -> Array.sortInPlace _. Key widgetCollectionAttributes
5763
58- EnvironmentAttributes = environmentAttributes |> ValueOption.map( Array.sortInPlace(_. Key)) }
64+ EnvironmentAttributes =
65+ match environmentAttributes with
66+ | [||] -> [||]
67+ | _ -> Array.sortInPlace _. Key environmentAttributes }
5968
6069 [<EditorBrowsable( EditorBrowsableState.Never) >]
6170 member inline x.AddScalar ( attr : ScalarAttribute ) =
@@ -103,14 +112,14 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =
103112
104113 let res =
105114 match attribs with
106- | ValueNone -> [| attr |]
107- | ValueSome attribs ->
115+ | [||] -> [| attr |]
116+ | attribs ->
108117 let attribs2 = Array.zeroCreate( attribs.Length + 1 )
109118 Array.blit attribs 0 attribs2 0 attribs.Length
110119 attribs2[ attribs.Length] <- attr
111120 attribs2
112121
113- WidgetBuilder< 'msg, 'marker>( x.Key, struct ( scalarAttributes, ValueSome res, widgetCollectionAttributes, environmentAttributes))
122+ WidgetBuilder< 'msg, 'marker>( x.Key, struct ( scalarAttributes, res, widgetCollectionAttributes, environmentAttributes))
114123
115124 [<EditorBrowsable( EditorBrowsableState.Never) >]
116125 member x.AddWidgetCollection ( attr : WidgetCollectionAttribute ) =
@@ -121,14 +130,14 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =
121130
122131 let res =
123132 match attribs with
124- | ValueNone -> [| attr |]
125- | ValueSome attribs ->
133+ | [||] -> [| attr |]
134+ | attribs ->
126135 let attribs2 = Array.zeroCreate( attribs.Length + 1 )
127136 Array.blit attribs 0 attribs2 0 attribs.Length
128137 attribs2[ attribs.Length] <- attr
129138 attribs2
130139
131- WidgetBuilder< 'msg, 'marker>( x.Key, struct ( scalarAttributes, widgetAttributes, ValueSome res, environmentAttributes))
140+ WidgetBuilder< 'msg, 'marker>( x.Key, struct ( scalarAttributes, widgetAttributes, res, environmentAttributes))
132141
133142 [<EditorBrowsable( EditorBrowsableState.Never) >]
134143 member inline x.AddEnvironment ( key : EnvironmentAttributeKey , value : obj ) =
@@ -146,14 +155,14 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =
146155
147156 let res =
148157 match attribs with
149- | ValueNone -> [| attr |]
150- | ValueSome attribs ->
158+ | [||] -> [| attr |]
159+ | attribs ->
151160 let attribs2 = Array.zeroCreate( attribs.Length + 1 )
152161 Array.blit attribs 0 attribs2 0 attribs.Length
153162 attribs2[ attribs.Length] <- attr
154163 attribs2
155164
156- WidgetBuilder< 'msg, 'marker>( x.Key, struct ( scalarAttributes, widgetAttributes, widgetCollectionAttributes, ValueSome res))
165+ WidgetBuilder< 'msg, 'marker>( x.Key, struct ( scalarAttributes, widgetAttributes, widgetCollectionAttributes, res))
157166 end
158167
159168
@@ -170,12 +179,12 @@ type CollectionBuilder<'msg, 'marker, 'itemMarker when 'msg: equality> =
170179
171180 new ( widgetKey: WidgetKey, scalars: StackList< ScalarAttribute>, attr: WidgetCollectionAttributeDefinition) =
172181 { WidgetKey = widgetKey
173- Attributes = AttributesBundle( scalars, ValueNone , ValueNone , ValueNone )
182+ Attributes = AttributesBundle( scalars, [||], [||], [||] )
174183 Attr = attr }
175184
176185 new ( widgetKey: WidgetKey, attr: WidgetCollectionAttributeDefinition) =
177186 { WidgetKey = widgetKey
178- Attributes = AttributesBundle( StackList.empty(), ValueNone , ValueNone , ValueNone )
187+ Attributes = AttributesBundle( StackList.empty(), [||], [||], [||] )
179188 Attr = attr }
180189
181190 new ( widgetKey: WidgetKey, attr: WidgetCollectionAttributeDefinition, attributes: AttributesBundle) =
@@ -185,12 +194,12 @@ type CollectionBuilder<'msg, 'marker, 'itemMarker when 'msg: equality> =
185194
186195 new ( widgetKey: WidgetKey, attr: WidgetCollectionAttributeDefinition, scalar: ScalarAttribute) =
187196 { WidgetKey = widgetKey
188- Attributes = AttributesBundle( StackList.one scalar, ValueNone , ValueNone , ValueNone )
197+ Attributes = AttributesBundle( StackList.one scalar, [||], [||], [||] )
189198 Attr = attr }
190199
191200 new ( widgetKey: WidgetKey, attr: WidgetCollectionAttributeDefinition, scalarA: ScalarAttribute, scalarB: ScalarAttribute) =
192201 { WidgetKey = widgetKey
193- Attributes = AttributesBundle( StackList.two( scalarA, scalarB), ValueNone , ValueNone , ValueNone )
202+ Attributes = AttributesBundle( StackList.two( scalarA, scalarB), [||], [||], [||] )
194203 Attr = attr }
195204
196205 member inline x.Run ( c : Content < 'msg >) =
@@ -205,8 +214,8 @@ type CollectionBuilder<'msg, 'marker, 'itemMarker when 'msg: equality> =
205214
206215 let widgetCollections =
207216 match widgetCollections with
208- | ValueNone -> ValueSome ( [| widgetCollAttr |])
209- | ValueSome widgetCollectionAttributes -> ValueSome ( Array.appendOne widgetCollAttr widgetCollectionAttributes)
217+ | [||] -> [| widgetCollAttr |]
218+ | widgetCollectionAttributes -> Array.appendOne widgetCollAttr widgetCollectionAttributes
210219
211220 WidgetBuilder< 'msg, 'marker>( x.WidgetKey, AttributesBundle( scalars, widgets, widgetCollections, environments))
212221
0 commit comments