Skip to content

Commit ec7ae46

Browse files
committed
Merge pull request #1206 from forki/toList
Remove Seq.toList when we already have a list
2 parents b846c90 + 740843c commit ec7ae46

File tree

7 files changed

+16
-29
lines changed

7 files changed

+16
-29
lines changed

src/absil/illib.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ type LayeredMultiMap<'Key,'Value when 'Key : equality and 'Key : comparison>(con
921921
x.MarkAsCollapsible()
922922
member x.MarkAsCollapsible() = LayeredMultiMap(contents.MarkAsCollapsible())
923923
member x.TryFind k = contents.TryFind k
924-
member x.Values = contents.Values |> Seq.concat
924+
member x.Values = contents.Values |> List.concat
925925
static member Empty : LayeredMultiMap<'Key,'Value> = LayeredMultiMap LayeredMap.Empty
926926

927927
[<AutoOpen>]

src/fsharp/CompileOps.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,8 +2793,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
27932793
|> List.map resolveLoadedSource
27942794
|> List.filter Option.isSome
27952795
|> List.map Option.get
2796-
|> Seq.distinct
2797-
|> Seq.toList
2796+
|> List.distinct
27982797

27992798
/// A closed set of assemblies where, for any subset S:
28002799
/// - the TcImports object built for S (and thus the F# Compiler CCUs for the assemblies in S)

src/fsharp/NameResolution.fs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,7 @@ let GetNestedTypesOfType (ad, ncenv:NameResolver, optFilter, staticResInfo, chec
10741074

10751075
| _ ->
10761076
#endif
1077-
mty.TypesByAccessNames.Values
1078-
|> Seq.toList
1077+
mty.TypesByAccessNames.Values
10791078
|> List.map (tcref.NestedTyconRef >> MakeNestedType ncenv tinst m)
10801079
|> List.filter (IsTypeAccessible g ncenv.amap m ad)
10811080
else [])
@@ -1540,8 +1539,7 @@ let CheckForTypeLegitimacyAndMultipleGenericTypeAmbiguities
15401539
let tcrefs =
15411540
tcrefs
15421541
// remove later duplicates (if we've opened the same module more than once)
1543-
|> Seq.distinctBy (fun (_,tcref) -> tcref.Stamp)
1544-
|> Seq.toList
1542+
|> List.distinctBy (fun (_,tcref) -> tcref.Stamp)
15451543
// List.sortBy is a STABLE sort (the order matters!)
15461544
|> List.sortBy (fun (_,tcref) -> tcref.Typars(m).Length)
15471545

@@ -3085,9 +3083,8 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
30853083

30863084
let ilTyconNames =
30873085
mty.TypesByAccessNames.Values
3088-
|> Seq.toList
30893086
|> List.choose (fun (tycon:Tycon) -> if tycon.IsILTycon then Some tycon.DisplayName else None)
3090-
|> Set.ofSeq
3087+
|> Set.ofList
30913088

30923089
match plid with
30933090
| [] ->
@@ -3168,17 +3165,15 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
31683165

31693166
let ilTyconNames =
31703167
nenv.TyconsByAccessNames(fullyQualified).Values
3171-
|> Seq.toList
31723168
|> List.choose (fun tyconRef -> if tyconRef.IsILTycon then Some tyconRef.DisplayName else None)
3173-
|> Set.ofSeq
3169+
|> Set.ofList
31743170

31753171
/// Include all the entries in the eUnqualifiedItems table.
31763172
let unqualifiedItems =
31773173
match fullyQualified with
31783174
| FullyQualified -> []
31793175
| OpenQualified ->
31803176
nenv.eUnqualifiedItems.Values
3181-
|> Seq.toList
31823177
|> List.filter (function Item.UnqualifiedType _ -> false | _ -> true)
31833178
|> List.filter (ItemIsUnseen ad g ncenv.amap m >> not)
31843179

@@ -3201,7 +3196,6 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
32013196

32023197
let tycons =
32033198
nenv.TyconsByDemangledNameAndArity(fullyQualified).Values
3204-
|> Seq.toList
32053199
|> List.filter (fun tcref -> not (tcref.LogicalName.Contains(",")))
32063200
|> List.filter (fun tcref -> not tcref.IsExceptionDecl)
32073201
|> List.filter (IsTyconUnseen ad g ncenv.amap m >> not)
@@ -3210,7 +3204,6 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
32103204
// Get all the constructors accessible from here
32113205
let constructors =
32123206
nenv.TyconsByDemangledNameAndArity(fullyQualified).Values
3213-
|> Seq.toList
32143207
|> List.filter (IsTyconUnseen ad g ncenv.amap m >> not)
32153208
|> List.collect (InfosForTyconConstructors ncenv m ad)
32163209

@@ -3266,9 +3259,8 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameRe
32663259

32673260
let ilTyconNames =
32683261
mty.TypesByAccessNames.Values
3269-
|> Seq.toList
32703262
|> List.choose (fun (tycon:Tycon) -> if tycon.IsILTycon then Some tycon.DisplayName else None)
3271-
|> Set.ofSeq
3263+
|> Set.ofList
32723264

32733265
match plid with
32743266
| [] ->
@@ -3333,9 +3325,8 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv:
33333325
// empty plid - return namespaces\modules\record types\accessible fields
33343326
let iltyconNames =
33353327
nenv.TyconsByAccessNames(fullyQualified).Values
3336-
|> Seq.toList
33373328
|> List.choose (fun tyconRef -> if tyconRef.IsILTycon then Some tyconRef.DisplayName else None)
3338-
|> Set.ofSeq
3329+
|> Set.ofList
33393330

33403331
let mods =
33413332
nenv.ModulesAndNamespaces(fullyQualified)
@@ -3348,7 +3339,6 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv:
33483339

33493340
let recdTyCons =
33503341
nenv.TyconsByDemangledNameAndArity(fullyQualified).Values
3351-
|> Seq.toList
33523342
|> List.filter (fun tcref -> not (tcref.LogicalName.Contains(",")))
33533343
|> List.filter (fun tcref -> tcref.IsRecordTycon)
33543344
|> List.filter (IsTyconUnseen ad g ncenv.amap m >> not)

src/fsharp/NicePrint.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module internal PrintUtilities =
5858

5959
let applyMaxMembers maxMembers (alldecls : _ list) =
6060
match maxMembers with
61-
| Some n when alldecls.Length > n -> (alldecls |> Seq.truncate n |> Seq.toList) @ [wordL "..."]
61+
| Some n when alldecls.Length > n -> (alldecls |> List.truncate n) @ [wordL "..."]
6262
| _ -> alldecls
6363

6464
/// fix up a name coming from IL metadata by quoting "funny" names (keywords, otherwise invalid identifiers)

src/fsharp/PostInferenceChecks.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ and CheckAttribs cenv env (attribs: Attribs) =
958958

959959
// Check for violations of allowMultiple = false
960960
let duplicates =
961-
tcrefs
961+
tcrefs
962962
|> Seq.groupBy (fun (tcref,_) -> tcref.Stamp)
963963
|> Seq.map (fun (_,elems) -> List.last (List.ofSeq elems), Seq.length elems)
964964
|> Seq.filter (fun (_,count) -> count > 1)

src/fsharp/TypeChecker.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4460,9 +4460,9 @@ and CrackStaticConstantArgs cenv env tpenv (staticParameters: Tainted<ProvidedPa
44604460
| SynType.StaticConstantNamed(SynType.LongIdent(LongIdentWithDots([id],_)),v,_) -> (Some id, v)
44614461
| v -> (None, v))
44624462
let unnamedArgs = args |> Seq.takeWhile (fst >> isNone) |> Seq.toArray |> Array.map snd
4463-
let otherArgs = args |> Seq.skipWhile (fst >> isNone) |> Seq.toList
4464-
let namedArgs = otherArgs |> Seq.takeWhile (fst >> isSome) |> Seq.toList |> List.map (map1Of2 Option.get)
4465-
let otherArgs = otherArgs |> Seq.skipWhile (fst >> isSome) |> Seq.toList
4463+
let otherArgs = args |> List.skipWhile (fst >> isNone)
4464+
let namedArgs = otherArgs |> List.takeWhile (fst >> isSome) |> List.map (map1Of2 Option.get)
4465+
let otherArgs = otherArgs |> List.skipWhile (fst >> isSome)
44664466
if not otherArgs.IsEmpty then
44674467
error (Error(FSComp.SR.etBadUnnamedStaticArgs(),m))
44684468
for (n,_) in namedArgs do
@@ -12382,8 +12382,8 @@ module TyconBindingChecking = begin
1238212382
| PassAIncrClassCtorJustAfterLastLet
1238312383
| PassAMember _ -> true
1238412384
let restRev = List.rev rest
12385-
let afterRev = restRev |> Seq.takeWhile isAfter |> Seq.toList
12386-
let beforeRev = restRev |> Seq.skipWhile isAfter |> Seq.toList
12385+
let afterRev = restRev |> List.takeWhile isAfter
12386+
let beforeRev = restRev |> List.skipWhile isAfter
1238712387

1238812388
[ yield! List.rev beforeRev
1238912389
yield PassAIncrClassCtorJustAfterLastLet

src/fsharp/lib.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ let fmap2Of2 f z (a1,a2) = let z,a2 = f z a2 in z,(a1,a2)
268268
module List =
269269
let noRepeats xOrder xs =
270270
let s = Zset.addList xs (Zset.empty xOrder) // build set
271-
Zset.elements s // get elements... no repeats
272-
273-
let groupBy f (xs:list<'T>) = xs |> Seq.groupBy f |> Seq.map (map2Of2 Seq.toList) |> Seq.toList
271+
Zset.elements s // get elements... no repeats
274272

275273
//---------------------------------------------------------------------------
276274
// Zmap rebinds

0 commit comments

Comments
 (0)