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

Commit050e7aa

Browse files
forkiKevinRansom
authored andcommitted
Do not iterate again to get minArgs length (#5091)
* Do not iterate again to get minArgs length* reuuse numParentTypars* reuse curriedArgInfos.Length* reuse sigArgInfos.Length* reuse sigArgInfos.Length* Reuse already calculated lengths* Only map suppliedArgs when we need it
1 parentad77930 commit050e7aa

File tree

5 files changed

+31
-29
lines changed

5 files changed

+31
-29
lines changed

‎src/fsharp/IlxGen.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,8 @@ let GetMethodSpecForMemberVal amap g (memberInfo:ValMemberInfo) (vref:ValRef) =
817817

818818
letthisTy=if isByrefTy g thisTythen destByrefTy g thisTyelse thisTy
819819
letthisArgTys= argsOfAppTy g thisTy
820-
ifctps.Length<> thisArgTys.Lengththen
821-
warning(InternalError(sprintf"CodeGen check: type checking did not quantify the correct number of type variables for this method, #parentTypars =%d, #ctps =%d, #mtps =%d, #thisArgTys =%d" numParentTypars ctps.Length mtps.Length thisArgTys.Length,m))
820+
ifnumParentTypars<> thisArgTys.Lengththen
821+
warning(InternalError(sprintf"CodeGen check: type checking did not quantify the correct number of type variables for this method, #parentTypars =%d, #mtps =%d, #thisArgTys =%d" numParentTypars mtps.Length thisArgTys.Length,m))
822822
else
823823
List.iter2
824824
(fun gtp ty2->

‎src/fsharp/MethodCalls.fs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,25 +254,25 @@ type CalledMeth<'T>
254254
| None->true)
255255

256256
// See if any of them are 'out' arguments being returned as part of a return tuple
257-
letunnamedCalledArgs,unnamedCalledOptArgs,unnamedCalledOutArgs=
257+
letminArgs,unnamedCalledArgs,unnamedCalledOptArgs,unnamedCalledOutArgs=
258258
letnUnnamedCallerArgs= unnamedCallerArgs.Length
259-
if allowOutAndOptArgs&& nUnnamedCallerArgs< unnamedCalledArgs.Lengththen
259+
letnUnnamedCalledArgs= unnamedCalledArgs.Length
260+
if allowOutAndOptArgs&& nUnnamedCallerArgs< nUnnamedCalledArgsthen
260261
letunnamedCalledArgsTrimmed,unnamedCalledOptOrOutArgs= List.chop nUnnamedCallerArgs unnamedCalledArgs
261262

262263
// Check if all optional/out arguments are byref-out args
263264
if unnamedCalledOptOrOutArgs|> List.forall(fun x-> x.IsOutArg&& isByrefTy g x.CalledArgumentType)then
264-
unnamedCalledArgsTrimmed,[], unnamedCalledOptOrOutArgs
265+
nUnnamedCallerArgs-1,unnamedCalledArgsTrimmed,[], unnamedCalledOptOrOutArgs
265266
// Check if all optional/out arguments are optional args
266267
elif unnamedCalledOptOrOutArgs|> List.forall(fun x-> x.OptArgInfo.IsOptional)then
267-
unnamedCalledArgsTrimmed, unnamedCalledOptOrOutArgs,[]
268+
nUnnamedCallerArgs-1,unnamedCalledArgsTrimmed, unnamedCalledOptOrOutArgs,[]
268269
// Otherwise drop them on the floor
269270
else
270-
unnamedCalledArgs,[],[]
271+
nUnnamedCalledArgs-1,unnamedCalledArgs,[],[]
271272
else
272-
unnamedCalledArgs,[],[]
273+
nUnnamedCalledArgs-1,unnamedCalledArgs,[],[]
273274

274275
let(unnamedCallerArgs,paramArrayCallerArgs),unnamedCalledArgs,paramArrayCalledArgOpt=
275-
letminArgs= unnamedCalledArgs.Length-1
276276
letsupportsParamArgs=
277277
allowParamArgs&&
278278
minArgs>=0&&

‎src/fsharp/QuotationTranslator.fs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
260260

261261
// Check to see if there aren't enough arguments or if there is a tuple-arity mismatch
262262
// If so, adjust and try again
263-
if curriedArgs.Length< curriedArgInfos.Length||
264-
((List.take curriedArgInfos.Length curriedArgs,curriedArgInfos)||> List.exists2(fun arg argInfo->
263+
letnCurriedArgInfos= curriedArgInfos.Length
264+
if curriedArgs.Length< nCurriedArgInfos||
265+
((List.take nCurriedArgInfos curriedArgs,curriedArgInfos)||> List.exists2(fun arg argInfo->
265266
(argInfo.Length>(tryDestRefTupleExpr arg).Length)))
266267
then
267268
if verboseCReflectthen
@@ -277,7 +278,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
277278
ConvExpr cenv env(MakeApplicationAndBetaReduce cenv.g(expr,exprty,[tyargs],curriedArgs,m))
278279
else
279280
// Too many arguments? Chop
280-
let(curriedArgs:Expr list),laterArgs= List.chopcurriedArgInfos.Length curriedArgs
281+
let(curriedArgs:Expr list),laterArgs= List.chopnCurriedArgInfos curriedArgs
281282

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

‎src/fsharp/SignatureConformance.fs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,15 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) =
232232
| Some(ValReprInfo(implTyparNames,implArgInfos,implRetInfo)as implValInfo), Some(ValReprInfo(sigTyparNames,sigArgInfos,sigRetInfo)as sigValInfo)->
233233
letntps= implTyparNames.Length
234234
letmtps= sigTyparNames.Length
235+
letnSigArgInfos= sigArgInfos.Length
235236
if ntps<> mtpsthen
236237
err(fun(x,y,z)-> FSComp.SR.ValueNotContainedMutabilityGenericParametersDiffer(x, y, z, string mtps, string ntps))
237238
elif implValInfo.KindsOfTypars<> sigValInfo.KindsOfTyparsthen
238239
err(FSComp.SR.ValueNotContainedMutabilityGenericParametersAreDifferentKinds)
239-
elifnot(sigArgInfos.Length<= implArgInfos.Length&& List.forall2(fun x y-> List.length x<= List.length y) sigArgInfos(fst(List.chopsigArgInfos.Length implArgInfos)))then
240-
err(fun(x,y,z)-> FSComp.SR.ValueNotContainedMutabilityAritiesDiffer(x, y, z, id.idText, stringsigArgInfos.Length, id.idText, id.idText))
240+
elifnot(nSigArgInfos<= implArgInfos.Length&& List.forall2(fun x y-> List.length x<= List.length y) sigArgInfos(fst(List.chopnSigArgInfos implArgInfos)))then
241+
err(fun(x,y,z)-> FSComp.SR.ValueNotContainedMutabilityAritiesDiffer(x, y, z, id.idText, stringnSigArgInfos, id.idText, id.idText))
241242
else
242-
letimplArgInfos= implArgInfos|> List.takesigArgInfos.Length
243+
letimplArgInfos= implArgInfos|> List.takenSigArgInfos
243244
letimplArgInfos=(implArgInfos, sigArgInfos)||> List.map2(fun l1 l2-> l1|> List.take l2.Length)
244245
// Propagate some information signature to implementation.
245246

‎src/fsharp/TastOps.fs‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6946,15 +6946,17 @@ let AdjustPossibleSubsumptionExpr g (expr: Expr) (suppliedArgs: Expr list) : (Ex
69466946
| Some id-> id.idText))
69476947
|_->
69486948
[]
6949-
6950-
assert(curriedActualArgTys.Length>= curriedNiceNames.Length)
6949+
6950+
letnCurriedNiceNames= curriedNiceNames.Length
6951+
assert(curriedActualArgTys.Length>= nCurriedNiceNames)
69516952

69526953
letargTysWithNiceNames,argTysWithoutNiceNames=
6953-
List.chopcurriedNiceNames.Length argTys
6954+
List.chopnCurriedNiceNames argTys
69546955

69556956
/// Only consume 'suppliedArgs' up to at most the number of nice arguments
6956-
letsuppliedArgs,droppedSuppliedArgs=
6957-
List.chop(min suppliedArgs.Length curriedNiceNames.Length) suppliedArgs
6957+
letnSuppliedArgs= min suppliedArgs.Length nCurriedNiceNames
6958+
letsuppliedArgs,droppedSuppliedArgs=
6959+
List.chop nSuppliedArgs suppliedArgs
69586960

69596961
/// The relevant range for any expressions and applications includes the arguments
69606962
letappm=(m, suppliedArgs)||> List.fold(fun m e-> unionRanges m(e.Range))
@@ -6965,7 +6967,7 @@ let AdjustPossibleSubsumptionExpr g (expr: Expr) (suppliedArgs: Expr list) : (Ex
69656967
// is a classic case. Here we generate
69666968
// let tmp = (effect;4) in
69676969
// (fun v -> Seq.take tmp (v :> seq<_>))
6968-
letbuildingLambdas=suppliedArgs.Length<>curriedNiceNames.Length
6970+
letbuildingLambdas=nSuppliedArgs<>nCurriedNiceNames
69696971

69706972
/// Given a tuple of argument variables that has a tuple type that satisfies the input argument types,
69716973
/// coerce it to a tuple that satisfies the matching coerced argument type(s).
@@ -7091,17 +7093,15 @@ let AdjustPossibleSubsumptionExpr g (expr: Expr) (suppliedArgs: Expr list) : (Ex
70917093
argTysWithoutNiceNames
70927094
(resVar, resVarAsExpr, retTy)
70937095

7094-
7095-
// Mark the up as Some/None
7096-
letsuppliedArgs= List.map Some suppliedArgs@ List.ofArray(Array.create(curriedNiceNames.Length- suppliedArgs.Length) None)
7097-
7098-
assert(suppliedArgs.Length= curriedNiceNames.Length)
7099-
7100-
letexprForAllArgs=
7101-
7096+
letexprForAllArgs=
71027097
if isNil argTysWithNiceNamesthen
71037098
mkCompGenLet appm cloVar exprWithActualTy exprForOtherArgs
71047099
else
7100+
// Mark the up as Some/None
7101+
letsuppliedArgs= List.map Some suppliedArgs@ List.replicate(nCurriedNiceNames- nSuppliedArgs) None
7102+
7103+
assert(suppliedArgs.Length= nCurriedNiceNames)
7104+
71057105
letlambdaBuilders,binderBuilders,inpsAsArgs=
71067106

71077107
(argTysWithNiceNames, curriedNiceNames, suppliedArgs)|||> List.map3(fun(_,inpArgTy,actualArgTys)niceNamessuppliedArg->

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp