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

Commite39cba2

Browse files
dotnet-botKevinRansom
authored andcommitted
Only compute suppressedMethNames if really needed (dotnet#5664) (dotnet#5705)
* Only compute suppressedMethNames if really needed* Use HashSet for addersAndRemovers* Only compute suppressedMethNames if really needed* move it to the right, sigh
1 parentcf6f7e2 commite39cba2

File tree

1 file changed

+81
-62
lines changed

1 file changed

+81
-62
lines changed

‎src/fsharp/NameResolution.fs‎

Lines changed: 81 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3507,13 +3507,11 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso
35073507
yield einfo.RemoveMethod.DisplayName]
35083508
else[]
35093509

3510-
letsuppressedMethNames= Zset.ofList String.order(pinfoMethNames@ einfoMethNames)
3511-
35123510
letpinfos=
35133511
pinfosIncludingUnseen
35143512
|> List.filter(fun x->not(PropInfoIsUnseen m x))
35153513

3516-
letminfoFilter(minfo:MethInfo)=
3514+
letminfoFilter(suppressedMethNames:Zset<_>)(minfo:MethInfo)=
35173515
letisApplicableMeth=
35183516
match completionTargetswith
35193517
| ResolveCompletionTargets.All x-> x
@@ -3574,45 +3572,55 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso
35743572
// REVIEW: add a name filter here in the common cases?
35753573
letminfos=
35763574
if completionTargets.ResolveAllthen
3577-
letminfos=
3578-
AllMethInfosOfTypeInScope ncenv.InfoReader nenv(None,ad) PreferOverrides m ty
3579-
|> List.filter minfoFilter
3580-
3581-
letminfos=
3582-
if isNil minfosthen[]else
3583-
letaddersAndRemovers=
3584-
lethashSet= HashSet()
3585-
for itemin pinfoItemsdo
3586-
match itemwith
3587-
| Item.Event(FSEvent(_,_,addValRef,removeValRef))->
3588-
hashSet.Add addValRef.LogicalName|> ignore
3589-
hashSet.Add removeValRef.LogicalName|> ignore
3590-
|_->()
3591-
hashSet
3575+
letminfos= AllMethInfosOfTypeInScope ncenv.InfoReader nenv(None,ad) PreferOverrides m ty
3576+
if isNil minfosthen
3577+
[]
3578+
else
3579+
letsuppressedMethNames= Zset.ofList String.order(pinfoMethNames@ einfoMethNames)
35923580

3593-
if addersAndRemovers.Count=0then minfos
3594-
else minfos|> List.filter(fun minfo->not(addersAndRemovers.Contains minfo.LogicalName))
3581+
letminfos=
3582+
minfos
3583+
|> List.filter(minfoFilter suppressedMethNames)
3584+
3585+
if isNil minfosthen
3586+
[]
3587+
else
3588+
letminfos=
3589+
letaddersAndRemovers=
3590+
lethashSet= HashSet()
3591+
for itemin pinfoItemsdo
3592+
match itemwith
3593+
| Item.Event(FSEvent(_,_,addValRef,removeValRef))->
3594+
hashSet.Add addValRef.LogicalName|> ignore
3595+
hashSet.Add removeValRef.LogicalName|> ignore
3596+
|_->()
3597+
hashSet
3598+
3599+
if addersAndRemovers.Count=0then minfos
3600+
else minfos|> List.filter(fun minfo->not(addersAndRemovers.Contains minfo.LogicalName))
35953601

35963602
#if!NO_EXTENSIONTYPING
3597-
// Filter out the ones with mangled names from applying static parameters
3598-
letminfos=
3599-
letmethsWithStaticParams=
3600-
minfos
3601-
|> List.filter(fun minfo->
3602-
match minfo.ProvidedStaticParameterInfowith
3603-
| Some(_methBeforeArguments, staticParams)-> staticParams.Length<>0
3604-
|_->false)
3605-
|> List.map(fun minfo-> minfo.DisplayName)
3606-
3607-
if methsWithStaticParams.IsEmptythen minfos
3608-
else minfos|> List.filter(fun minfo->
3609-
letnm= minfo.LogicalName
3610-
not(nm.Contains","&& methsWithStaticParams|> List.exists(fun m-> nm.StartsWithOrdinal(m))))
3603+
// Filter out the ones with mangled names from applying static parameters
3604+
letminfos=
3605+
letmethsWithStaticParams=
3606+
minfos
3607+
|> List.filter(fun minfo->
3608+
match minfo.ProvidedStaticParameterInfowith
3609+
| Some(_methBeforeArguments, staticParams)-> staticParams.Length<>0
3610+
|_->false)
3611+
|> List.map(fun minfo-> minfo.DisplayName)
3612+
3613+
if methsWithStaticParams.IsEmptythen minfos
3614+
else minfos|> List.filter(fun minfo->
3615+
letnm= minfo.LogicalName
3616+
not(nm.Contains","&& methsWithStaticParams|> List.exists(fun m-> nm.StartsWithOrdinal(m))))
36113617
#endif
36123618

3613-
minfos
3619+
minfos
3620+
3621+
else
3622+
[]
36143623

3615-
else[]
36163624
// Partition methods into overload sets
36173625
let recpartitionl(l:MethInfo list)acc=
36183626
match lwith
@@ -4185,13 +4193,12 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty (
41854193
yield einfo.AddMethod.DisplayName
41864194
yield einfo.RemoveMethod.DisplayName]
41874195

4188-
letsuppressedMethNames= Zset.ofList String.order(pinfoMethNames@ einfoMethNames)
41894196

41904197
letpinfos=
41914198
pinfosIncludingUnseen
41924199
|> List.filter(fun x->not(PropInfoIsUnseen m x))
41934200

4194-
letminfoFilter(minfo:MethInfo)=
4201+
letminfoFilter(suppressedMethNames:Zset<_>)(minfo:MethInfo)=
41954202
// Only show the Finalize, MemberwiseClose etc. methods on System.Object for values whose static type really is
41964203
// System.Object. Few of these are typically used from F#.
41974204
//
@@ -4242,37 +4249,49 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty (
42424249
| Item.MethodGroup_->
42434250
// REVIEW: add a name filter here in the common cases?
42444251
letminfos=
4245-
letminfos=
4246-
AllMethInfosOfTypeInScope ncenv.InfoReader nenv(None,ad) PreferOverrides m ty
4247-
|> List.filter minfoFilter
4248-
4252+
letminfos= AllMethInfosOfTypeInScope ncenv.InfoReader nenv(None,ad) PreferOverrides m ty
4253+
if isNil minfosthen[]else
4254+
4255+
letsuppressedMethNames= Zset.ofList String.order(pinfoMethNames@ einfoMethNames)
42494256
letminfos=
4250-
letaddersAndRemovers=
4251-
pinfoItems
4252-
|> List.collect(function Item.Event(FSEvent(_,_,addValRef,removeValRef))->[addValRef.LogicalName;removeValRef.LogicalName]|_->[])
4253-
|> set
4257+
minfos
4258+
|> List.filter(minfoFilter suppressedMethNames)
42544259

4255-
if addersAndRemovers.IsEmptythen minfos
4256-
else minfos|> List.filter(fun minfo->not(addersAndRemovers.Contains minfo.LogicalName))
4260+
if isNil minfosthen
4261+
[]
4262+
else
4263+
letminfos=
4264+
letaddersAndRemovers=
4265+
lethashSet= HashSet()
4266+
for itemin pinfoItemsdo
4267+
match itemwith
4268+
| Item.Event(FSEvent(_,_,addValRef,removeValRef))->
4269+
hashSet.Add addValRef.LogicalName|> ignore
4270+
hashSet.Add removeValRef.LogicalName|> ignore
4271+
|_->()
4272+
hashSet
4273+
4274+
if addersAndRemovers.Count=0then minfos
4275+
else minfos|> List.filter(fun minfo->not(addersAndRemovers.Contains minfo.LogicalName))
42574276

42584277
#if!NO_EXTENSIONTYPING
4259-
// Filter out the ones with mangled names from applying static parameters
4260-
letminfos=
4261-
letmethsWithStaticParams=
4262-
minfos
4263-
|> List.filter(fun minfo->
4264-
match minfo.ProvidedStaticParameterInfowith
4265-
| Some(_methBeforeArguments, staticParams)-> staticParams.Length<>0
4266-
|_->false)
4267-
|> List.map(fun minfo-> minfo.DisplayName)
4278+
// Filter out the ones with mangled names from applying static parameters
4279+
letminfos=
4280+
letmethsWithStaticParams=
4281+
minfos
4282+
|> List.filter(fun minfo->
4283+
match minfo.ProvidedStaticParameterInfowith
4284+
| Some(_methBeforeArguments, staticParams)-> staticParams.Length<>0
4285+
|_->false)
4286+
|> List.map(fun minfo-> minfo.DisplayName)
42684287

4269-
if methsWithStaticParams.IsEmptythen minfos
4270-
else minfos|> List.filter(fun minfo->
4271-
letnm= minfo.LogicalName
4272-
not(nm.Contains","&& methsWithStaticParams|> List.exists(fun m-> nm.StartsWithOrdinal(m))))
4288+
if methsWithStaticParams.IsEmptythen minfos
4289+
else minfos|> List.filter(fun minfo->
4290+
letnm= minfo.LogicalName
4291+
not(nm.Contains","&& methsWithStaticParams|> List.exists(fun m-> nm.StartsWithOrdinal(m))))
42734292
#endif
42744293

4275-
minfos
4294+
minfos
42764295

42774296
// Partition methods into overload sets
42784297
let recpartitionl(l:MethInfo list)acc=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp