Skip to content

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

Merged
merged 2 commits into from
May 12, 2025
Merged

Optimize #1103

merged 2 commits into from
May 12, 2025

Conversation

kerams
Copy link
Contributor

@kerams kerams commented May 12, 2025

No description provided.

@@ -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 ())
Copy link
Contributor Author

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>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes indirection.

Comment on lines -261 to +262
| Few of data: struct (Size * 'v * 'v * 'v)
| Many of arr: 'v array
| Few of data: Size * 'v * 'v * 'v
Copy link
Contributor Author

@kerams kerams May 12, 2025

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
Copy link
Contributor Author

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.

@edgarfgp
Copy link
Member

Thanks @kerams

@edgarfgp edgarfgp merged commit ae87b8e into fabulous-dev:main May 12, 2025
1 check passed
@kerams kerams deleted the opt branch May 12, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants