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

Commit61a165e

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Replace List.chop with List.splitAt and remove its own List.take from illib (#5090)
* replace List.chop with List.splitAtremove List.take from illib.fs* replace List.splitAt >> fst with List.take* use List.truncate instead of List.take* Revert "replace List.splitAt >> fst with List.take"This reverts commit c4f06057724f6e2fc7c85c49c236903352ac629f.* Revert "Revert "replace List.splitAt >> fst with List.take""This reverts commit 2cb969341dc6031e63856db314671f5969db7aeb.* Revert "replace List.chop with List.splitAt"This reverts commit cde206bd17de9e4724c949c3c4f77ff2864af23e.# Conflicts:#src/fsharp/SignatureConformance.fs* remove List.take from illib.fs and replace its usages with List.truncate* Revert "remove List.take from illib.fs and replace its usages with List.truncate"This reverts commit 8a198b0334ada7990f5804afe800b89915b69d46.# Conflicts:#src/fsharp/DetupleArgs.fs* Revert "Revert "remove List.take from illib.fs and replace its usages with List.truncate""This reverts commit 6722f08faae33b6b8262f67482385a81f3616dcd.* rollback accidental change
1 parent6f8f5f2 commit61a165e

15 files changed

+29
-48
lines changed

‎src/absil/illib.fs‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -279,30 +279,11 @@ module List =
279279
|[]-> None
280280
| h::t->if f hthen Some(h,n)else findi(n+1) f t
281281

282-
letchop n l=
283-
if n= List.length lthen(l,[])else// avoids allocation unless necessary
284-
let recloop n l acc=
285-
if n<=0then(List.rev acc,l)else
286-
match lwith
287-
|[]-> failwith"List.chop: overchop"
288-
|(h::t)-> loop(n-1) t(h::acc)
289-
loop n l[]
290-
291-
lettake n l=
292-
if n= List.length lthen lelse
293-
let recloop acc n l=
294-
match lwith
295-
|[]-> List.rev acc
296-
| x::xs->if n<=0then List.rev accelse loop(x::acc)(n-1) xs
297-
298-
loop[] n l
299-
300282
let recdrop n l=
301283
match lwith
302284
|[]->[]
303285
|_::xs->if n=0then lelse drop(n-1) xs
304286

305-
306287
letsplitChoose select l=
307288
let recch acc1 acc2 l=
308289
match lwith

‎src/fsharp/DetupleArgs.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,16 @@ let decideTransform g z v callPatterns (m, tps, vss:Val list list, rty) =
562562
(* NOTE: 'a in arg types may have been instanced at different tuples...*)
563563
(* commonCallPattern has to handle those cases.*)
564564
letcallPattern= commonCallPattern callPatterns// common CallPattern
565-
letcallPattern= List.take vss.Length callPattern// restricted to max nArgs
565+
letcallPattern= List.truncate vss.Length callPattern// restricted to max nArgs
566566
// Get formal callPattern by defn usage of formals
567567
letformalCallPattern= decideFormalSuggestedCP g z tys vss
568-
letcallPattern= List.take callPattern.Length formalCallPattern
568+
letcallPattern= List.truncate callPattern.Length formalCallPattern
569569
// Zip with information about known args
570570
letcallPattern,tyfringes= zipCallPatternArgTys m g callPattern vss
571571
// Drop trivial tail AND
572572
letcallPattern= minimalCallPattern callPattern
573573
// Shorten tyfringes (zippable)
574-
lettyfringes= List.take callPattern.Length tyfringes
574+
lettyfringes= List.truncate callPattern.Length tyfringes
575575
if isTrivialCP callPatternthen
576576
None// no transform
577577
else
@@ -791,7 +791,7 @@ let passBind penv (TBind(fOrig, repr, letSeqPtOpt) as bind) =
791791
letp= transformedFormals.Length
792792
if(vss.Length< p)then internalError"passBinds: |vss|<p - detuple pass"
793793
letxqNs= List.drop p vss
794-
letx1ps= List.take p vss
794+
letx1ps= List.truncate p vss
795795
lety1Ps= List.concat(List.map2 transFormal transformedFormals x1ps)
796796
letformals= y1Ps@ xqNs
797797
// fCBody - parts

‎src/fsharp/IlxGen.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ let GetMethodSpecForMemberVal amap g (memberInfo:ValMemberInfo) (vref:ValRef) =
797797
letparentTypars= parentTcref.TyparsNoRange
798798
letnumParentTypars= parentTypars.Length
799799
if tps.Length< numParentTyparsthen error(InternalError("CodeGen check: type checking did not ensure that this method is sufficiently generic", m))
800-
letctps,mtps= List.chop numParentTypars tps
800+
letctps,mtps= List.splitAt numParentTypars tps
801801
letisCompiledAsInstance= ValRefIsCompiledAsInstanceMember g vref
802802

803803
letilActualRetTy=
@@ -2615,7 +2615,7 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel =
26152615
| Method(topValInfo,vref,mspec,_,_,_,_)->
26162616
letnowArgs,laterArgs=
26172617
let_,curriedArgInfos,_,_= GetTopValTypeInFSharpForm cenv.g topValInfo vref.Type m
2618-
List.chop curriedArgInfos.Length args
2618+
List.splitAt curriedArgInfos.Length args
26192619

26202620
letactualRetTy= applyTys cenv.g vref.Type(tyargs,nowArgs)
26212621
let_,curriedArgInfos,returnTy,_= GetTopValTypeInCompiledForm cenv.g topValInfo vref.Type m
@@ -2637,7 +2637,7 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel =
26372637

26382638
let(ilEnclArgTys,ilMethArgTys)=
26392639
if ilTyArgs.Length< numEnclILTypeArgsthen error(InternalError("length mismatch",m))
2640-
List.chop numEnclILTypeArgs ilTyArgs
2640+
List.splitAt numEnclILTypeArgs ilTyArgs
26412641

26422642
letboxity= mspec.DeclaringType.Boxity
26432643
letmspec= mkILMethSpec(mspec.MethodRef, boxity,ilEnclArgTys,ilMethArgTys)

‎src/fsharp/InnerLambdasToTopLevelFuncs.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ module Pass4_RewriteAssembly =
988988
// Take off the variables
989989
lettps,vss,b,rty= stripTopLambda(b,f.Type)
990990
// Don't take all the variables - only up to length wf
991-
letvssTake,vssDrop= List.chop wf vss
991+
letvssTake,vssDrop= List.splitAt wf vss
992992
// put the variables back on
993993
letb,rty= mkMultiLambdasCore b.Range vssDrop(b,rty)
994994
// fHat, args

‎src/fsharp/MethodCalls.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ type CalledMeth<'T>
258258
letnUnnamedCallerArgs= unnamedCallerArgs.Length
259259
letnUnnamedCalledArgs= unnamedCalledArgs.Length
260260
if allowOutAndOptArgs&& nUnnamedCallerArgs< nUnnamedCalledArgsthen
261-
letunnamedCalledArgsTrimmed,unnamedCalledOptOrOutArgs= List.chop nUnnamedCallerArgs unnamedCalledArgs
261+
letunnamedCalledArgsTrimmed,unnamedCalledOptOrOutArgs= List.splitAt nUnnamedCallerArgs unnamedCalledArgs
262262

263263
// Check if all optional/out arguments are byref-out args
264264
if unnamedCalledOptOrOutArgs|> List.forall(fun x-> x.IsOutArg&& isByrefTy g x.CalledArgumentType)then
@@ -280,7 +280,7 @@ type CalledMeth<'T>
280280

281281
if supportsParamArgs&& unnamedCallerArgs.Length>= minArgsthen
282282
leta,b= List.frontAndBack unnamedCalledArgs
283-
List.chop minArgs unnamedCallerArgs, a, Some(b)
283+
List.splitAt minArgs unnamedCallerArgs, a, Some(b)
284284
else
285285
(unnamedCallerArgs,[]), unnamedCalledArgs, None
286286

@@ -651,7 +651,7 @@ let BuildFSharpMethodApp g m (vref: ValRef) vexp vexprty (args: Exprs) =
651651
|1,[]-> error(InternalError("expected additional arguments here", m))
652652
|_->
653653
if args.Length< aritythen error(InternalError("internal error in getting arguments, n ="+string arity+", #args ="+string args.Length, m));
654-
lettupargs,argst= List.chop arity args
654+
lettupargs,argst= List.splitAt arity args
655655
lettuptys= tupargs|> List.map(tyOfExpr g)
656656
(mkRefTupled g m tupargs tuptys),
657657
(argst, rangeOfFunTy g fty))

‎src/fsharp/NameResolution.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3188,7 +3188,7 @@ let ComputeItemRange wholem (lid: Ident list) rest =
31883188
match restwith
31893189
|[]-> wholem
31903190
|_->
3191-
letids= List.take(max0(lid.Length- rest.Length)) lid
3191+
letids= List.truncate(max0(lid.Length- rest.Length)) lid
31923192
match idswith
31933193
|[]-> wholem
31943194
|_-> rangeOfLid ids

‎src/fsharp/NicePrint.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ module private PrintIL =
170170
match System.Int32.TryParse(rightMost, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture)with
171171
|true, n-> n
172172
|false,_->0// looks like it's non-generic
173-
ilTyparSubst|> List.rev|> List.take numParms|> List.rev
173+
ilTyparSubst|> List.rev|> List.truncate numParms|> List.rev
174174

175175
let reclayoutILType(denv:DisplayEnv)(ilTyparSubst:layout list)(ty:ILType):layout=
176176
match tywith

‎src/fsharp/Optimizer.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,7 @@ and OptimizeApplication cenv env (f0, f0ty, tyargs, args, m) =
25902590
letnDetupArgsL= detupArgsL.Length
25912591
letnShapes= min nargs nDetupArgsL
25922592
letdetupArgsShapesL=
2593-
List.take nShapes detupArgsL
2593+
List.truncate nShapes detupArgsL
25942594
|> List.map(fun detupArgs->
25952595
match detupArgswith
25962596
|[]|[_]-> UnknownValue

‎src/fsharp/QuotationTranslator.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
262262
// If so, adjust and try again
263263
letnCurriedArgInfos= curriedArgInfos.Length
264264
if curriedArgs.Length< nCurriedArgInfos||
265-
((List.take nCurriedArgInfos curriedArgs,curriedArgInfos)||> List.exists2(fun arg argInfo->
265+
((List.truncate nCurriedArgInfos curriedArgs,curriedArgInfos)||> List.exists2(fun arg argInfo->
266266
(argInfo.Length>(tryDestRefTupleExpr arg).Length)))
267267
then
268268
if verboseCReflectthen
@@ -278,7 +278,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
278278
ConvExpr cenv env(MakeApplicationAndBetaReduce cenv.g(expr,exprty,[tyargs],curriedArgs,m))
279279
else
280280
// Too many arguments? Chop
281-
let(curriedArgs:Expr list),laterArgs= List.chop nCurriedArgInfos curriedArgs
281+
let(curriedArgs:Expr list),laterArgs= List.splitAt nCurriedArgInfos curriedArgs
282282

283283
letcallR=
284284
// We now have the right number of arguments, w.r.t. currying and tupling.

‎src/fsharp/SignatureConformance.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) =
237237
err(fun(x,y,z)-> FSComp.SR.ValueNotContainedMutabilityGenericParametersDiffer(x, y, z, string mtps, string ntps))
238238
elif implValInfo.KindsOfTypars<> sigValInfo.KindsOfTyparsthen
239239
err(FSComp.SR.ValueNotContainedMutabilityGenericParametersAreDifferentKinds)
240-
elifnot(nSigArgInfos<= implArgInfos.Length&& List.forall2(fun x y-> List.length x<= List.length y) sigArgInfos(fst(List.chop nSigArgInfos implArgInfos)))then
240+
elifnot(nSigArgInfos<= implArgInfos.Length&& List.forall2(fun x y-> List.length x<= List.length y) sigArgInfos(fst(List.splitAt nSigArgInfos implArgInfos)))then
241241
err(fun(x,y,z)-> FSComp.SR.ValueNotContainedMutabilityAritiesDiffer(x, y, z, id.idText, string nSigArgInfos, id.idText, id.idText))
242242
else
243-
letimplArgInfos= implArgInfos|> List.take nSigArgInfos
243+
letimplArgInfos= implArgInfos|> List.truncate nSigArgInfos
244244
letimplArgInfos=(implArgInfos, sigArgInfos)||> List.map2(fun l1 l2-> l1|> List.take l2.Length)
245245
// Propagate some information signature to implementation.
246246

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp