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

Commita91dd03

Browse files
forkiKevinRansom
authored andcommitted
Remove some concats and use some indexed (dotnet#2216)
1 parent86ea292 commita91dd03

File tree

7 files changed

+17
-24
lines changed

7 files changed

+17
-24
lines changed

‎src/absil/illib.fs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,6 @@ module NameMap =
758758

759759
letiter f(l:NameMap<'T>)= Map.iter(fun _k v-> f v) l
760760

761-
letiteri f(l:NameMap<'T>)= Map.iter f l
762-
763-
letmapi f(l:NameMap<'T>)= Map.map f l
764-
765761
letpartition f(l:NameMap<'T>)= Map.filter(fun _ x-> f x) l, Map.filter(fun _ x->not(f x)) l
766762

767763
letmem v(m:NameMap<'T>)= Map.containsKey v m

‎src/absil/ilwritepdb.fs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ let fixupOverlappingSequencePoints fixupSPs showTimes methods =
230230
// length of all sequence point marks so they do not go further than
231231
// the next sequence point in the source.
232232
letspCounts= methods|> Array.map(fun x-> x.SequencePoints.Length)
233-
letallSps= methods|> Array.map(fun x-> x.SequencePoints)
234-
|> Array.concat
233+
letallSps= methods|> Array.collect(fun x-> x.SequencePoints)
235234
|> Array.mapi(fun i sp-> i, sp)
236235
if fixupSPsthen
237236
// sort the sequence points into source order
@@ -546,10 +545,9 @@ let writePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info cvChunk =
546545
// partition of the source code of a method. So here we shorten the
547546
// length of all sequence point marks so they do not go further than
548547
// the next sequence point in the source.
549-
letspCounts= info.Methods|> Array.map(fun x-> x.SequencePoints.Length)
550-
letallSps= Array.concat(Array.map(fun x-> x.SequencePoints) info.Methods|> Array.toList)
551-
letallSps= Array.mapi(fun i sp->(i,sp)) allSps
552-
if fixupOverlappingSequencePointsthen
548+
letspCounts= info.Methods|> Array.map(fun x-> x.SequencePoints.Length)
549+
letallSps= Array.collect(fun x-> x.SequencePoints) info.Methods|> Array.indexed
550+
if fixupOverlappingSequencePointsthen
553551
// sort the sequence points into source order
554552
Array.sortInPlaceWith(fun(_,sp1)(_,sp2)-> SequencePoint.orderBySource sp1 sp2) allSps
555553
// shorten the ranges of any that overlap with following sequence points

‎src/fsharp/CompileOps.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,7 +2940,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
29402940
// In the grouped reference, store the index of the last use of the reference.
29412941
letgroupedReferences=
29422942
originalReferences
2943-
|> List.mapi(fun index reference->(index, reference))
2943+
|> List.indexed
29442944
|> Seq.groupBy(fun(_,reference)-> reference.Text)
29452945
|> Seq.map(fun(assemblyName,assemblyAndIndexGroup)->
29462946
letassemblyAndIndexGroup= assemblyAndIndexGroup|> List.ofSeq
@@ -3035,7 +3035,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
30353035
|> Array.concat
30363036
|> Array.sortBy fst
30373037
|> Array.map snd
3038-
|> List.ofArray
3038+
|> List.ofArray
30393039
|> List.concat
30403040

30413041
// O(N^2) here over a small set of referenced assemblies.

‎src/fsharp/IlxGen.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ let ChooseParamNames fieldNamesAndTypes =
7777
letilParamName=if takenFieldNames.Contains(lowerPropName)then ilPropNameelse lowerPropName
7878
ilParamName,ilFieldName,ilPropType)
7979

80-
letmarkup s=s|>Seq.mapi(fun i x-> i,x)
80+
letmarkup s= Seq.indexed s
8181

8282
// Approximation for purposes of optimization and giving a warning when compiling definition-only files as EXEs
8383
let recCheckCodeDoesSomething(code:ILCode)=

‎src/fsharp/TastOps.fs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,19 +2477,19 @@ let layoutOfPath p =
24772477
letfullNameOfParentOfPubPath pp=
24782478
match ppwith
24792479
| PubPath([|_|])-> None
2480-
| pp-> Some(textOfPath(Array.toList pp.EnclosingPath))
2480+
| pp-> Some(textOfPath pp.EnclosingPath)
24812481

24822482
letfullNameOfParentOfPubPathAsLayout pp=
24832483
match ppwith
24842484
| PubPath([|_|])-> None
24852485
| pp-> Some(layoutOfPath(Array.toList pp.EnclosingPath))
24862486

2487-
letfullNameOfPubPath(PubPath(p))= textOfPath(Array.toList p)
2487+
letfullNameOfPubPath(PubPath(p))= textOfPathp
24882488
letfullNameOfPubPathAsLayout(PubPath(p))= layoutOfPath(Array.toList p)
24892489

24902490
letfullNameOfParentOfNonLocalEntityRef(nlr:NonLocalEntityRef)=
24912491
if nlr.Path.Length=0|| nlr.Path.Length=1then None
2492-
else Some(textOfArrPath nlr.EnclosingMangledPath)// <--- BAD BAD BAD: this is a mangled path. This is wrong for nested modules
2492+
else Some(textOfPath nlr.EnclosingMangledPath)// <--- BAD BAD BAD: this is a mangled path. This is wrong for nested modules
24932493

24942494
letfullNameOfParentOfNonLocalEntityRefAsLayout(nlr:NonLocalEntityRef)=
24952495
if nlr.Path.Length=0|| nlr.Path.Length=1then None
@@ -4596,7 +4596,7 @@ and remapParentRef tyenv p =
45964596
| Parent x-> Parent(x|> remapTyconRef tyenv.tyconRefRemap)
45974597

45984598
andmapImmediateValsAndTycons ft fv(x:ModuleOrNamespaceType)=
4599-
letvals= x.AllValsAndMembers|> QueueList.map fv
4599+
letvals= x.AllValsAndMembers|> QueueList.map fv
46004600
lettycons= x.AllEntities|> QueueList.map ft
46014601
new ModuleOrNamespaceType(x.ModuleOrNamespaceKind, vals, tycons)
46024602

@@ -5997,7 +5997,7 @@ let permuteExprList (sigma:int[]) (exprs: Expr list) (typ: TType list) (names:st
59975997
else
59985998
expri, rbinds
59995999

6000-
letnewExprs,reversedBinds= List.mapFold rewrite[](exprs|> List.mapi(fun i x->(i,x)))
6000+
letnewExprs,reversedBinds= List.mapFold rewrite[](exprs|> List.indexed)
60016001
letbinds= List.rev reversedBinds
60026002
letreorderedExprs= permute sigma(Array.ofList newExprs)
60036003
binds,Array.toList reorderedExprs
@@ -6016,12 +6016,12 @@ let mkRecordExpr g (lnk,tcref,tinst,rfrefs:RecdFieldRef list,args,m) =
60166016
// Remove any abbreviations
60176017
lettcref,tinst= destAppTy g(mkAppTy tcref tinst)
60186018

6019-
letrfrefsArray= rfrefs|> List.mapi(fun i x->(i,x))|> Array.ofList
6020-
rfrefsArray|> Array.sortInPlaceBy(fun(_,r)-> r.Index);
6019+
letrfrefsArray= rfrefs|> List.indexed|> Array.ofList
6020+
rfrefsArray|> Array.sortInPlaceBy(fun(_,r)-> r.Index)
60216021
letsigma= Array.create rfrefsArray.Length-1
60226022
Array.iteri(fun j(i,_)->
6023-
if sigma.[i]<>-1then error(InternalError("bad permutation",m));
6024-
sigma.[i]<- j) rfrefsArray;
6023+
if sigma.[i]<>-1then error(InternalError("bad permutation",m))
6024+
sigma.[i]<- j) rfrefsArray
60256025

60266026
letargTyps= List.map(fun rfref-> actualTyOfRecdFieldRef rfref tinst) rfrefs
60276027
letnames= rfrefs|> List.map(fun rfref-> rfref.FieldName)

‎src/fsharp/ast.fs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,6 @@ let textOfId (id:Ident) = id.idText
14751475
letpathOfLid lid= List.map textOfId lid
14761476
letarrPathOfLid lid= Array.ofList(pathOfLid lid)
14771477
lettextOfPath path= String.concat"." path
1478-
lettextOfArrPath path= String.concat"."(List.ofArray path)
14791478
lettextOfLid lid= textOfPath(pathOfLid lid)
14801479

14811480
letrangeOfLid(lid:Ident list)=

‎src/utils/sformat.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat
733733
// showL
734734
// ------------------------------------------------------------------------
735735

736-
letcombine strs= System.String.Concat(Array.ofList(strs): string[])
736+
letcombine(strs:string list)= System.String.Concat strs
737737
letshowL opts leafFormatter layout=
738738
letpush x rstrs= x::rstrs
739739
letz0=[],0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp