Skip to content
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

Don't create dict for empty lists #5348

Merged
merged 3 commits into from
Jul 22, 2018
Merged

Don't create dict for empty lists #5348

merged 3 commits into from
Jul 22, 2018

Conversation

forki
Copy link
Contributor

@forki forki commented Jul 18, 2018

As in most other list operation implementations we should shortcut empty lists

Copy link
Member

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

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

Better investigate the failures.

@KevinRansom
Copy link
Member

Those failures don't really look related. Let's try again.

@dotnet build test this

@KevinRansom
Copy link
Member

@dotnet-bot test this please

@forki forki closed this Jul 19, 2018
@forki forki deleted the groupBy branch July 19, 2018 07:21
@forki forki reopened this Jul 19, 2018
@forki forki restored the groupBy branch July 19, 2018 07:22
@@ -405,10 +405,12 @@ namespace Microsoft.FSharp.Collections
loop 0

let inline groupByImpl (comparer:IEqualityComparer<'SafeKey>) (keyf:'T->'SafeKey) (getKey:'SafeKey->'Key) (array: 'T[]) =
let length = array.Length
if length = 0 then Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked 0 else
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's time to add empty arrays singleton? #5066 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. I could use them in many places

@forki forki changed the title [WIP] Don't create dict for empty lists Don't create dict for empty lists Jul 19, 2018
@forki
Copy link
Contributor Author

forki commented Jul 19, 2018

this is ready

@KevinRansom
Copy link
Member

@forki thanks for this mate.

@KevinRansom KevinRansom merged commit eb32ee8 into dotnet:master Jul 22, 2018
@forki forki mentioned this pull request Jul 23, 2018
@dsyme
Copy link
Contributor

dsyme commented Nov 20, 2018

@KevinRansom As mentioned in #5942 this is an incorrect optimization. We should revert and publish a new version of FSharp.Core assuming this has made it out into the wild (I think it has)

@cartermp
Copy link
Contributor

@dsyme Yes, it's out in the wild. We need to revert this and #5942.

@forki
Copy link
Contributor Author

forki commented Nov 20, 2018

ouch. apologies. @cartermp we also need some kind of test here

@forki forki deleted the groupBy branch November 20, 2018 21:56
KevinRansom pushed a commit that referenced this pull request Nov 26, 2018
* Fix and tests, unbuilt and untested

* Correct one of the tests

Got the order wrong for the output of `countBy`.

* Repair the groupBy test

groupBy test was bad: it assumed (ridiculously) that groupBy wouldn't iterate the original sequence even though it somehow knew the groups in the sequence.
KevinRansom pushed a commit to KevinRansom/fsharp that referenced this pull request Nov 26, 2018
… (dotnet#5947)

* Fix and tests, unbuilt and untested

* Correct one of the tests

Got the order wrong for the output of `countBy`.

* Repair the groupBy test

groupBy test was bad: it assumed (ridiculously) that groupBy wouldn't iterate the original sequence even though it somehow knew the groups in the sequence.
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.

None yet

5 participants