Skip to content

Commit 998a9d4

Browse files
committed
Refactor
1 parent a47cf35 commit 998a9d4

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/Fabulous/Array.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module Array =
6161
let inline sortInPlace<'T, 'V when 'V: comparison> ([<InlineIfLambda>] getKey: 'T -> 'V) (attrs: 'T[]) : 'T[] =
6262
let N = attrs.GetLength(0)
6363

64-
for i in [ 1 .. N - 1 ] do
64+
for i in 1 .. N - 1 do
6565
for j = i downto 1 do
6666
let key = getKey attrs[j]
6767
let prevKey = getKey attrs[j - 1]

src/Fabulous/Builders.fs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,22 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =
5252
| _ -> Array.sortInPlace _.Key (StackList.toArray &scalarAttributes)
5353

5454
WidgetAttributes =
55-
match widgetAttributes with
56-
| [||] -> [||]
57-
| _ -> Array.sortInPlace _.Key widgetAttributes
55+
if widgetAttributes.Length > 1 then
56+
Array.sortInPlace _.Key widgetAttributes
57+
else
58+
widgetAttributes
5859

5960
WidgetCollectionAttributes =
60-
match widgetCollectionAttributes with
61-
| [||] -> [||]
62-
| _ -> Array.sortInPlace _.Key widgetCollectionAttributes
61+
if widgetCollectionAttributes.Length > 1 then
62+
Array.sortInPlace _.Key widgetCollectionAttributes
63+
else
64+
widgetCollectionAttributes
6365

6466
EnvironmentAttributes =
65-
match environmentAttributes with
66-
| [||] -> [||]
67-
| _ -> Array.sortInPlace _.Key environmentAttributes }
67+
if environmentAttributes.Length > 1 then
68+
Array.sortInPlace _.Key environmentAttributes
69+
else
70+
environmentAttributes }
6871

6972
[<EditorBrowsable(EditorBrowsableState.Never)>]
7073
member inline x.AddScalar(attr: ScalarAttribute) =

0 commit comments

Comments
 (0)