Skip to content

Speed up Array extensions - #507

Merged
gusty merged 6 commits into
fsprojects:masterfrom
fcallejon:fcallejon/arrays_update_replace
Oct 3, 2022
Merged

gusty merged 6 commits into
fsprojects:masterfrom
fcallejon:fcallejon/arrays_update_replace

Conversation

@fcallejon

Copy link
Copy Markdown
Member

No description provided.

Comment thread src/FSharpPlus/Extensions/Array.fs Outdated
| null -> null
| [||] -> [||]
| _ ->
let candidate = new ResizeArray<'T>()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Try ArrayCollector instead, I think it's faster.

@gusty gusty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Excellent !
Looks good to me, just a few details.

Comment on lines +57 to +60
match source with
| null -> null
| [||] -> [||]
| _ ->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should remove null handling for the moment until we agree on a general strategy.

Comment thread src/FSharpPlus/Extensions/Array.fs Outdated
oldValueIndexRight <- oldValueIndexRight - 1

if matchingElements then
candidate.AddRange(newValue)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Parens around newValue might not be needed.
Same below.

Comment thread src/FSharpPlus/Extensions/Array.fs Outdated
&& source.[sourceIndex + oldValueIndexRight] = oldValue.[oldValueIndexRight]

while oldValueIndexLeft <= middleIndex
&& oldValueIndexRight >= middleIndex

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's use 4 spaces indent, so add 2 spaces here

@fcallejon
fcallejon marked this pull request as ready for review October 3, 2022 20:24
@fcallejon
fcallejon requested a review from gusty October 3, 2022 20:28

@gusty gusty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, thanks !

@gusty gusty changed the title Update Arrays Speed up Array extensions Oct 3, 2022
@gusty
gusty merged commit c56866c into fsprojects:master Oct 3, 2022
@fcallejon
fcallejon deleted the fcallejon/arrays_update_replace branch October 4, 2022 17:16
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