Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe5cb58

Browse files
forkiKevinRansom
authored andcommitted
Empty shortcuts (#5370)
* Empty shortcuts* Empty shortcuts* Empty shortcuts
1 parent5410276 commitbe5cb58

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

‎src/fsharp/FSharp.Core/array.fs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ namespace Microsoft.FSharp.Collections
163163
Microsoft.FSharp.Primitives.Basics.Array.subUnchecked0 count array
164164

165165
let inlinecountByImpl(comparer:IEqualityComparer<'SafeKey>)(projection:'T->'SafeKey)(getKey:'SafeKey->'Key)(array:'T[])=
166+
letlength= array.Length
167+
if length=0then Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked0else
168+
166169
letdict= Dictionary comparer
167170

168171
// Build the groupings
@@ -279,6 +282,9 @@ namespace Microsoft.FSharp.Collections
279282
[<CompiledName("DistinctBy")>]
280283
letdistinctBy projection(array:'T[])=
281284
checkNonNull"array" array
285+
letlength= array.Length
286+
if length=0then Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked0else
287+
282288
lettemp= Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked array.Length
283289
let mutablei=0
284290
lethashSet= HashSet<_>(HashIdentity.Structural<_>)

‎src/fsharp/FSharp.Core/list.fs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ namespace Microsoft.FSharp.Collections
4848
letconcat lists= Microsoft.FSharp.Primitives.Basics.List.concat lists
4949

5050
let inlinecountByImpl(comparer:IEqualityComparer<'SafeKey>)(projection:'T->'SafeKey)(getKey:'SafeKey->'Key)(list:'T list)=
51+
match listwith
52+
|[]->[]
53+
|_->
54+
5155
letdict= Dictionary comparer
5256
let recloop srcList=
5357
match srcListwith

‎src/fsharp/FSharp.Core/seq.fs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ namespace Microsoft.FSharp.Collections
10871087
[<CompiledName("Distinct")>]
10881088
letdistinct source=
10891089
checkNonNull"source" source
1090+
if isEmpty sourcethen emptyelse
10901091
seq{lethashSet= HashSet<'T>(HashIdentity.Structural<'T>)
10911092
for vin sourcedo
10921093
if hashSet.Add(v)then
@@ -1095,6 +1096,7 @@ namespace Microsoft.FSharp.Collections
10951096
[<CompiledName("DistinctBy")>]
10961097
letdistinctBy projection source=
10971098
checkNonNull"source" source
1099+
if isEmpty sourcethen emptyelse
10981100
seq{lethashSet= HashSet<_>(HashIdentity.Structural<_>)
10991101
for vin sourcedo
11001102
if hashSet.Add(projection v)then
@@ -1138,6 +1140,7 @@ namespace Microsoft.FSharp.Collections
11381140

11391141
let inlinecountByImpl(comparer:IEqualityComparer<'SafeKey>)(keyf:'T->'SafeKey)(getKey:'SafeKey->'Key)(source:seq<'T>)=
11401142
checkNonNull"source" source
1143+
if isEmpty sourcethen emptyelse
11411144

11421145
letdict= Dictionary comparer
11431146

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp