Skip to content

Commit

Permalink
Merge branch 'main' into release/3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Nov 22, 2024
2 parents 1c19484 + 8bd2605 commit ed54775
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 52 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_No unreleased changes_

## [3.0.0-pre16] - 2024-11-22

### Changed
- Small optimization when building for AOT by @TimLariviere

### Removed
- Removed `SingleChildBuilder` due to its big impact on AOT compilation compared to the low benefits on development experience by @TimLariviere

## [3.0.0-pre15] - 2024-11-21

### Added
Expand Down Expand Up @@ -192,7 +200,8 @@ _No unreleased changes_
### Changed
- Fabulous.XamarinForms & Fabulous.MauiControls have been moved been out of the Fabulous repository. Find them in their own repositories: [https://github.com/fabulous-dev/Fabulous.XamarinForms](https://github.com/fabulous-dev/Fabulous.XamarinForms) / [https://github.com/fabulous-dev/Fabulous.MauiControls](https://github.com/fabulous-dev/Fabulous.MauiControls)

[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre15...HEAD
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre16...HEAD
[3.0.0-pre16]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre16
[3.0.0-pre15]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre15
[3.0.0-pre14]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre14
[3.0.0-pre13]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre13
Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous/Array.fs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module ArraySlice =
module Array =
let inline appendOne (v: 'v) (arr: 'v array) =
let res = Array.zeroCreate(arr.Length + 1)
Array.blit arr 0 res 0 arr.Length
res[..arr.Length - 1] <- arr
res[arr.Length] <- v
res

Expand Down
49 changes: 0 additions & 49 deletions src/Fabulous/Builders.fs
Original file line number Diff line number Diff line change
Expand Up @@ -279,52 +279,3 @@ type AttributeCollectionBuilder<'msg, 'marker, 'itemMarker when 'msg: equality>

res
end

type SingleChildBuilderStep<'msg, 'marker when 'msg: equality> = delegate of unit -> WidgetBuilder<'msg, 'marker>

[<Struct>]
type SingleChildBuilder<'msg, 'marker, 'childMarker when 'msg: equality> =
val WidgetKey: WidgetKey
val Attr: WidgetAttributeDefinition
val AttributesBundle: AttributesBundle

new(widgetKey: WidgetKey, attr: WidgetAttributeDefinition) =
{ WidgetKey = widgetKey
Attr = attr
AttributesBundle = AttributesBundle(StackList.empty(), ValueNone, ValueNone, ValueNone) }

new(widgetKey: WidgetKey, attr: WidgetAttributeDefinition, attributesBundle: AttributesBundle) =
{ WidgetKey = widgetKey
Attr = attr
AttributesBundle = attributesBundle }

member inline this.Yield(widget: WidgetBuilder<'msg, 'childMarker>) =
SingleChildBuilderStep(fun () -> widget)

member inline this.Combine
([<InlineIfLambda>] a: SingleChildBuilderStep<'msg, 'childMarker>, [<InlineIfLambda>] _b: SingleChildBuilderStep<'msg, 'childMarker>)
=
SingleChildBuilderStep(fun () ->
// We only want one child, so we ignore the second one
a.Invoke())

member inline this.Delay([<InlineIfLambda>] fn: unit -> SingleChildBuilderStep<'msg, 'childMarker>) =
SingleChildBuilderStep(fun () -> fn().Invoke())

member inline this.Run([<InlineIfLambda>] result: SingleChildBuilderStep<'msg, 'childMarker>) =
let childAttr = this.Attr.WithValue(result.Invoke().Compile())

let struct (scalars, widgets, widgetCollections, environments) =
this.AttributesBundle

WidgetBuilder<'msg, 'marker>(
this.WidgetKey,
AttributesBundle(
scalars,
(match widgets with
| ValueNone -> ValueSome [| childAttr |]
| ValueSome widgets -> ValueSome(Array.appendOne childAttr widgets)),
widgetCollections,
environments
)
)
2 changes: 1 addition & 1 deletion src/Fabulous/Components/ComponentContext.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type ComponentContext(initialSize: int) =
if values.Length < count then
let newLength = max (values.Length * 2) count
let newArray = Array.zeroCreate newLength
Array.blit values 0 newArray 0 values.Length
newArray[..values.Length - 1] <- values
values <- newArray

member this.TryGetValue<'T>(key: int) =
Expand Down

0 comments on commit ed54775

Please sign in to comment.