-
-
Notifications
You must be signed in to change notification settings - Fork 122
Optimize #1103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize #1103
Conversation
src/Fabulous/Array.fs
Outdated
@@ -49,7 +49,7 @@ module ArraySlice = | |||
module Array = | |||
let inline appendOne (v: 'v) (arr: 'v array) = | |||
let res = Array.zeroCreate(arr.Length + 1) | |||
res[.. arr.Length - 1] <- arr | |||
arr.CopyTo (res.AsSpan ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is several times faster.
@@ -89,7 +89,7 @@ module StackAllocatedCollections = | |||
[<NoComparison; NoEquality>] | |||
type private Part<'v> = | |||
| Empty | |||
| Filled of struct (Items<'v> * Part<'v>) | |||
| Filled of Items<'v> * Part<'v> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removes indirection.
| Few of data: struct (Size * 'v * 'v * 'v) | ||
| Many of arr: 'v array | ||
| Few of data: Size * 'v * 'v * 'v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removes indirection and decreases total DU struct size with some type parameters (48 to 40 bytes for string
).
| Added of added: uint16 | ||
| Removed of removed: uint16 | ||
| Changed of changed: uint16 | ||
|
||
| Added of value: uint16 | ||
| Removed of value: uint16 | ||
| Changed of value: uint16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merges fields and reduces struct size from 12 to 8 bytes.
Thanks @kerams |
No description provided.