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

Commitc1249ec

Browse files
forkiKevinRansom
authored andcommitted
We should not demangling twice (dotnet#2208)
* We should not demangling twice* map + concat => collect* Tycons are calculated even if they are not used* Tycons are calculated even if they are not used* map + concat => collect
1 parent9f3f779 commitc1249ec

File tree

5 files changed

+50
-52
lines changed

5 files changed

+50
-52
lines changed

‎src/fsharp/CompileOps.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4864,7 +4864,7 @@ module private ScriptPreprocessClosure =
48644864
//printfn "yielding non-script source %s" filename
48654865
yield ClosureFile(filename, m, None,[],[],[])]
48664866

4867-
closureSources|> List.map loop|> List.concat,!tcConfig
4867+
closureSources|> List.collect loop,!tcConfig
48684868

48694869
/// Reduce the full directive closure into LoadClosure
48704870
letGetLoadClosure(rootFilename,closureFiles,tcConfig:TcConfig,codeContext)=
@@ -4948,7 +4948,7 @@ module private ScriptPreprocessClosure =
49484948
/// Used from fsi.fs and fsc.fs, for #load and command line
49494949
letGetFullClosureOfScriptFiles(tcConfig:TcConfig,files:(string*range)list,codeContext,lexResourceManager:Lexhelp.LexResourceManager)=
49504950
letmainFile= fst(List.last files)
4951-
letclosureSources= files|> List.map(fun(filename,m)-> ClosureSourceOfFilename(filename,m,tcConfig.inputCodePage,true))|> List.concat
4951+
letclosureSources= files|> List.collect(fun(filename,m)-> ClosureSourceOfFilename(filename,m,tcConfig.inputCodePage,true))
49524952
letclosureFiles,tcConfig= FindClosureFiles(closureSources,tcConfig,codeContext,lexResourceManager)
49534953
GetLoadClosure(mainFile,closureFiles,tcConfig,codeContext)
49544954

‎src/fsharp/CompileOptions.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ let PrintCompilerOptionBlocks blocks =
145145
if Set.contains heading doneHeadingsthen
146146
doneHeadings
147147
else
148-
letheadingOptions= List.filter(fst>> equals heading) publicBlocks|> List.map snd|> List.concat
148+
letheadingOptions= List.filter(fst>> equals heading) publicBlocks|> List.collect snd
149149
PrintPublicOptions(heading,headingOptions)
150150
Set.add heading doneHeadings
151151
List.fold consider Set.empty publicBlocks|> ignore<Set<string>>

‎src/fsharp/NameResolution.fs‎

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ type Item =
220220
| Item.Types(nm,_)-> DemangleGenericTypeName nm
221221
| Item.UnqualifiedType(tcref::_)-> tcref.DisplayName
222222
| Item.TypeVar(nm,_)-> nm
223-
| Item.ModuleOrNamespaces(modref::_)->modref.DemangledModuleOrNamespaceName
223+
| Item.ModuleOrNamespaces(modref::_)-> modref.DemangledModuleOrNamespaceName
224224
| Item.ArgName(id,_,_)-> id.idText
225225
| Item.SetterArg(id,_)-> id.idText
226226
| Item.CustomOperation(customOpName,_,_)-> customOpName
@@ -3431,8 +3431,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso
34313431
letminfos=
34323432
letaddersAndRemovers=
34333433
pinfoItems
3434-
|> List.map(function Item.Event(FSEvent(_,_,addValRef,removeValRef))->[addValRef.LogicalName;removeValRef.LogicalName]|_->[])
3435-
|> List.concat
3434+
|> List.collect(function Item.Event(FSEvent(_,_,addValRef,removeValRef))->[addValRef.LogicalName;removeValRef.LogicalName]|_->[])
34363435
|> set
34373436

34383437
if addersAndRemovers.IsEmptythen minfos
@@ -3591,18 +3590,17 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
35913590
letg= ncenv.g
35923591
letmty= modref.ModuleOrNamespaceType
35933592

3594-
lettycons=
3595-
mty.TypeDefinitions
3596-
|> List.filter(fun tcref->not(tcref.LogicalName.Contains(",")))
3597-
|> List.filter(fun tycon->not(IsTyconUnseen ad g ncenv.amap m(modref.NestedTyconRef tycon)))
3598-
3599-
letilTyconNames=
3600-
mty.TypesByAccessNames.Values
3601-
|> List.choose(fun(tycon:Tycon)->if tycon.IsILTyconthen Some tycon.DisplayNameelse None)
3602-
|> Set.ofList
3603-
36043593
match plidwith
36053594
|[]->
3595+
lettycons=
3596+
mty.TypeDefinitions
3597+
|> List.filter(fun tcref->not(tcref.LogicalName.Contains(",")))
3598+
|> List.filter(fun tycon->not(IsTyconUnseen ad g ncenv.amap m(modref.NestedTyconRef tycon)))
3599+
3600+
letilTyconNames=
3601+
mty.TypesByAccessNames.Values
3602+
|> List.choose(fun(tycon:Tycon)->if tycon.IsILTyconthen Some tycon.DisplayNameelse None)
3603+
|> Set.ofList
36063604

36073605
// Collect up the accessible values in the module, excluding the members
36083606
(mty.AllValsAndMembers
@@ -3615,8 +3613,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
36153613
// Collect up the accessible discriminated union cases in the module
36163614
@(UnionCaseRefsInModuleOrNamespace modref
36173615
|> List.filter(IsUnionCaseUnseen ad g ncenv.amap m>>not)
3618-
|> List.map GeneralizeUnionCaseRef
3619-
|> List.map(fun x-> Item.UnionCase(x,false)))
3616+
|> List.map(fun x-> Item.UnionCase(GeneralizeUnionCaseRef x,false)))
36203617

36213618
// Collect up the accessible active patterns in the module
36223619
@(ActivePatternElemsOfModuleOrNamespace modref
@@ -3635,8 +3632,9 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
36353632
// Collect up the accessible sub-modules
36363633
@(mty.ModulesAndNamespacesByDemangledName
36373634
|> NameMap.range
3638-
|> List.filter(fun x-> x.DemangledModuleOrNamespaceName|> notFakeContainerModule ilTyconNames)
3639-
|> List.filter(fun x-> x.DemangledModuleOrNamespaceName|> IsInterestingModuleName)
3635+
|> List.filter(fun x->
3636+
letdemangledName= x.DemangledModuleOrNamespaceName
3637+
notFakeContainerModule ilTyconNames demangledName&& IsInterestingModuleName demangledName)
36403638
|> List.map modref.NestedTyconRef
36413639
|> List.filter(IsTyconUnseen ad g ncenv.amap m>>not)
36423640
|> List.filter(EntityRefContainsSomethingAccessible ncenv m ad)
@@ -3647,7 +3645,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
36473645
|> List.map(modref.NestedTyconRef>> ItemOfTyconRef ncenv m))
36483646

36493647
@(tycons
3650-
|> List.map(modref.NestedTyconRef>> InfosForTyconConstructors ncenv m ad)|> List.concat)
3648+
|> List.collect(modref.NestedTyconRef>> InfosForTyconConstructors ncenv m ad))
36513649

36523650
| id:: rest->
36533651

@@ -3671,7 +3669,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
36713669
let recResolvePartialLongIdentPrim(ncenv:NameResolver)(nenv:NameResolutionEnv)isApplicableMeth fullyQualified m ad plid allowObsolete=
36723670
letg= ncenv.g
36733671

3674-
matchplidwith
3672+
match plidwith
36753673
| id:: plidwhen id="global"->// this is deliberately not the mangled name
36763674

36773675
ResolvePartialLongIdentPrim ncenv nenv isApplicableMeth FullyQualified m ad plid allowObsolete
@@ -3703,8 +3701,9 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
37033701
letmoduleAndNamespaceItems=
37043702
nenv.ModulesAndNamespaces(fullyQualified)
37053703
|> NameMultiMap.range
3706-
|> List.filter(fun x-> x.DemangledModuleOrNamespaceName|> IsInterestingModuleName)
3707-
|> List.filter(fun x-> x.DemangledModuleOrNamespaceName|> notFakeContainerModule ilTyconNames)
3704+
|> List.filter(fun x->
3705+
letdemangledName= x.DemangledModuleOrNamespaceName
3706+
IsInterestingModuleName demangledName&& notFakeContainerModule ilTyconNames demangledName)
37083707
|> List.filter(EntityRefContainsSomethingAccessible ncenv m ad)
37093708
|> List.filter(IsTyconUnseen ad g ncenv.amap m>>not)
37103709
|> List.map ItemForModuleOrNamespaceRef
@@ -3764,26 +3763,27 @@ let ResolvePartialLongIdent ncenv nenv isApplicableMeth m ad plid allowObsolete
37643763
let recResolvePartialLongIdentInModuleOrNamespaceForRecordFields(ncenv:NameResolver)nenv m ad(modref:ModuleOrNamespaceRef)plid allowObsolete=
37653764
letg= ncenv.g
37663765
letmty= modref.ModuleOrNamespaceType
3767-
3768-
// get record type constructors
3769-
lettycons=
3770-
mty.TypeDefinitions
3771-
|> List.filter(fun tcref->not(tcref.LogicalName.Contains(",")))
3772-
|> List.filter(fun tycon-> tycon.IsRecordTycon)
3773-
|> List.filter(fun tycon->not(IsTyconUnseen ad g ncenv.amap m(modref.NestedTyconRef tycon)))
3774-
3775-
letilTyconNames=
3776-
mty.TypesByAccessNames.Values
3777-
|> List.choose(fun(tycon:Tycon)->if tycon.IsILTyconthen Some tycon.DisplayNameelse None)
3778-
|> Set.ofList
3779-
3766+
37803767
match plidwith
37813768
|[]->
3769+
// get record type constructors
3770+
lettycons=
3771+
mty.TypeDefinitions
3772+
|> List.filter(fun tcref->not(tcref.LogicalName.Contains(",")))
3773+
|> List.filter(fun tycon-> tycon.IsRecordTycon)
3774+
|> List.filter(fun tycon->not(IsTyconUnseen ad g ncenv.amap m(modref.NestedTyconRef tycon)))
3775+
3776+
letilTyconNames=
3777+
mty.TypesByAccessNames.Values
3778+
|> List.choose(fun(tycon:Tycon)->if tycon.IsILTyconthen Some tycon.DisplayNameelse None)
3779+
|> Set.ofList
3780+
37823781
// Collect up the accessible sub-modules
37833782
(mty.ModulesAndNamespacesByDemangledName
37843783
|> NameMap.range
3785-
|> List.filter(fun x-> x.DemangledModuleOrNamespaceName|> notFakeContainerModule ilTyconNames)
3786-
|> List.filter(fun x-> x.DemangledModuleOrNamespaceName|> IsInterestingModuleName)
3784+
|> List.filter(fun x->
3785+
letdemangledName= x.DemangledModuleOrNamespaceName
3786+
notFakeContainerModule ilTyconNames demangledName&& IsInterestingModuleName demangledName)
37873787
|> List.map modref.NestedTyconRef
37883788
|> List.filter(IsTyconUnseen ad g ncenv.amap m>>not)
37893789
|> List.filter(EntityRefContainsSomethingAccessible ncenv m ad)
@@ -3817,8 +3817,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameRe
38173817
|> List.collect(fun tycon->
38183818
lettcref= modref.NestedTyconRef tycon
38193819
letttype= FreshenTycon ncenv m tcref
3820-
ncenv.InfoReader.GetRecordOrClassFieldsOfType(None, ad, m, ttype)
3821-
)
3820+
ncenv.InfoReader.GetRecordOrClassFieldsOfType(None, ad, m, ttype))
38223821
|> List.map Item.RecdField
38233822
|_->[]
38243823
)
@@ -3846,8 +3845,9 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv:
38463845
letmods=
38473846
nenv.ModulesAndNamespaces(fullyQualified)
38483847
|> NameMultiMap.range
3849-
|> List.filter(fun x-> x.DemangledModuleOrNamespaceName|> IsInterestingModuleName)
3850-
|> List.filter(fun x-> x.DemangledModuleOrNamespaceName|> notFakeContainerModule iltyconNames)
3848+
|> List.filter(fun x->
3849+
letdemangledName= x.DemangledModuleOrNamespaceName
3850+
IsInterestingModuleName demangledName&& notFakeContainerModule iltyconNames demangledName)
38513851
|> List.filter(EntityRefContainsSomethingAccessible ncenv m ad)
38523852
|> List.filter(IsTyconUnseen ad g ncenv.amap m>>not)
38533853
|> List.map ItemForModuleOrNamespaceRef
@@ -3864,8 +3864,7 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv:
38643864
|> Seq.collect(fun(KeyValue(_,v))-> v)
38653865
|> Seq.map(fun fref->
38663866
lettypeInsts= fref.TyconRef.TyparsNoRange|> List.map(fun tyar-> tyar.AsType)
3867-
Item.RecdField(RecdFieldInfo(typeInsts, fref))
3868-
)
3867+
Item.RecdField(RecdFieldInfo(typeInsts, fref)))
38693868
|> List.ofSeq
38703869

38713870
mods@ recdTyCons@ recdFields
@@ -3887,8 +3886,7 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv:
38873886
tycons
38883887
|> List.collect(fun tcref->
38893888
letttype= FreshenTycon ncenv m tcref
3890-
ncenv.InfoReader.GetRecordOrClassFieldsOfType(None, ad, m, ttype)
3891-
)
3889+
ncenv.InfoReader.GetRecordOrClassFieldsOfType(None, ad, m, ttype))
38923890
|> List.map Item.RecdField
38933891
|_->[]
38943892
modsOrNs@ qualifiedFields

‎src/fsharp/TypeChecker.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12583,7 +12583,7 @@ module IncrClassChecking =
1258312583
// Now deal with all the 'let' and 'member' declarations
1258412584
let initActions,reps = List.mapFold TransDec reps decs
1258512585
let cctorInitActions2, ctorInitActions2,methodBinds2 = List.unzip3 initActions
12586-
let cctorInitActions = cctorInitActions1 @List.concat cctorInitActions2
12586+
let cctorInitActions = cctorInitActions1 @ List.concat cctorInitActions2
1258712587
let ctorInitActions = ctorInitActions1 @ List.concat ctorInitActions2
1258812588
let methodBinds = methodBinds1 @ List.concat methodBinds2
1258912589

@@ -12759,7 +12759,7 @@ module MutRecBindingChecking =
1275912759
[ for (RecDefnBindingInfo(a,b,c,bind)) in recBinds do
1276012760
yield NormalizedRecBindingDefn(a,b,c,BindingNormalization.NormalizeBinding ValOrMemberBinding cenv envForDecls bind) ]
1276112761
let bindsAndValues,(tpenv,recBindIdx) = ((tpenv,recBindIdx), normRecDefns) ||> List.mapFold (AnalyzeAndMakeAndPublishRecursiveValue ErrorOnOverrides false cenv envForDecls)
12762-
let binds = bindsAndValues |> List.map fst |> List.concat
12762+
let binds = bindsAndValues |> List.collect fst
1276312763

1276412764
let defnAs = MutRecShape.Lets binds
1276512765
defnAs,(tpenv,recBindIdx,List.rev binds @ uncheckedBindsRev)
@@ -14118,7 +14118,7 @@ module TcExceptionDeclarations =
1411814118

1411914119
let defns = [MutRecShape.Tycon(MutRecDefnsPhase2DataForTycon(Some exnc, parent, ModuleOrMemberBinding, mkLocalEntityRef exnc, None, NoSafeInitInfo, [], aug, m, NoNewSlots, (fun () -> ())))]
1412014120
let binds2,envFinal = TcMutRecDefns_Phase2 cenv envInitial m scopem None envMutRec defns
14121-
let binds2flat = binds2 |> MutRecShapes.collectTycons |> List.map snd |> List.concat
14121+
let binds2flat = binds2 |> MutRecShapes.collectTycons |> List.collect snd
1412214122
// Augment types with references to values that implement the pre-baked semantics of the type
1412314123
let binds3 = AddAugmentationDeclarations.AddGenericEqualityBindings cenv envFinal exnc
1412414124
binds1 @ binds2flat @ binds3,exnc,envFinal

‎src/fsharp/fsc.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ let AdjustForScriptCompile(tcConfigB:TcConfigBuilder, commandLineSourceFiles, le
215215
letclosure= LoadClosure.ComputeClosureOfSourceFiles(tcConfig,[filename, rangeStartup], CodeContext.Compilation, lexResourceManager=lexResourceManager)
216216
// Record the references from the analysis of the script. The full resolutions are recorded as the corresponding #I paths used to resolve them
217217
// are local to the scripts and not added to the tcConfigB (they are added to localized clones of the tcConfigB).
218-
letreferences= closure.References|> List.map snd|> List.concat|> List.filter(fun r->r.originalReference.Range<>range0&& r.originalReference.Range<>rangeStartup)
218+
letreferences= closure.References|> List.collect snd|> List.filter(fun r->r.originalReference.Range<>range0&& r.originalReference.Range<>rangeStartup)
219219
references|> List.iter(fun r-> tcConfigB.AddReferencedAssemblyByPath(r.originalReference.Range, r.resolvedPath))
220-
closure.NoWarns|> List.map(fun(n,ms)->ms|>List.map(fun m->m, n))|> List.concat|> List.iter tcConfigB.TurnWarningOff
220+
closure.NoWarns|> List.collect(fun(n,ms)->ms|>List.map(fun m->m, n))|> List.iter tcConfigB.TurnWarningOff
221221
closure.SourceFiles|> List.map fst|> List.iter AddIfNotPresent
222222
closure.AllRootFileDiagnostics|> List.iter diagnosticSink
223223

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp