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

Commitda13079

Browse files
committed
Improve perf of unused opens analysis
1 parent4952f84 commitda13079

File tree

7 files changed

+316
-93
lines changed

7 files changed

+316
-93
lines changed

‎src/fsharp/NameResolution.fs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,12 +1330,18 @@ let (|ActivePatternCaseUse|_|) (item:Item) =
13301330
| Item.ActivePatternResult(ap,_, idx,_)-> Some(ap.Range, ap.Range, idx)
13311331
|_-> None
13321332

1333+
lettyconRefDefnHash(_g:TcGlobals)(eref1:EntityRef)=
1334+
hash eref1.LogicalName
1335+
13331336
lettyconRefDefnEq g(eref1:EntityRef)(eref2:EntityRef)=
13341337
tyconRefEq g eref1 eref2
13351338
// Signature items considered equal to implementation items
13361339
||((eref1.DefinitionRange= eref2.DefinitionRange|| eref1.SigRange= eref2.SigRange)&&
13371340
(eref1.LogicalName= eref2.LogicalName))
13381341

1342+
letvalRefDefnHash(_g:TcGlobals)(vref1:ValRef)=
1343+
hash vref1.DisplayName
1344+
13391345
letvalRefDefnEq g(vref1:ValRef)(vref2:ValRef)=
13401346
valRefEq g vref1 vref2
13411347
// Signature items considered equal to implementation items
@@ -1410,6 +1416,23 @@ let ItemsAreEffectivelyEqual g orig other =
14101416

14111417
|_->false
14121418

1419+
/// Given the Item 'orig' - returns function 'other : Item -> bool', that will yield true if other and orig represents the same item and false - otherwise
1420+
letItemsAreEffectivelyEqualHash(g:TcGlobals)orig=
1421+
match origwith
1422+
| EntityUse tcref-> tyconRefDefnHash g tcref
1423+
| Item.TypeVar(nm,_)-> hash nm
1424+
| ValUse vref-> valRefDefnHash g vref
1425+
| ActivePatternCaseUse(_,_, idx)-> hash idx
1426+
| MethodUse minfo-> minfo.ComputeHashCode()
1427+
| PropertyUse pinfo-> pinfo.ComputeHashCode()
1428+
| Item.ArgName(id,_,_)-> hash id.idText
1429+
| ILFieldUse ilfinfo-> ilfinfo.ComputeHashCode()
1430+
| UnionCaseUse ucase-> hash ucase.CaseName
1431+
| RecordFieldUse(name,_)-> hash name
1432+
| EventUse einfo-> einfo.ComputeHashCode()
1433+
| Item.ModuleOrNamespaces_->100013
1434+
|_->389329
1435+
14131436
[<System.Diagnostics.DebuggerDisplay("{DebugToString()}")>]
14141437
typeCapturedNameResolution(p:pos,i:Item,tpinst,io:ItemOccurence,de:DisplayEnv,nre:NameResolutionEnv,ad:AccessorDomain,m:range)=
14151438
memberthis.Pos= p

‎src/fsharp/NameResolution.fsi‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ type internal ItemOccurence =
251251
/// Check for equality, up to signature matching
252252
valItemsAreEffectivelyEqual:TcGlobals->Item->Item->bool
253253

254+
/// Hash compatible with ItemsAreEffectivelyEqual
255+
valItemsAreEffectivelyEqualHash:TcGlobals->Item->int
256+
254257
[<Class>]
255258
typeinternalCapturedNameResolution=
256259
/// line and column

‎src/fsharp/infos.fs‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ type MethInfo =
12401240

12411241
/// Tests whether two method infos have the same underlying definition.
12421242
/// Used to merge operator overloads collected from left and right of an operator constraint.
1243+
/// Must be compatible with ItemsAreEffectivelyEqual relation.
12431244
static memberMethInfosUseIdenticalDefinitions x1 x2=
12441245
match x1,x2with
12451246
| ILMeth(_,x1,_), ILMeth(_,x2,_)->(x1.RawMetadata=== x2.RawMetadata)
@@ -1250,8 +1251,7 @@ type MethInfo =
12501251
#endif
12511252
|_->false
12521253

1253-
/// Calculates a hash code of method info. Note: this is a very imperfect implementation,
1254-
/// but it works decently for comparing methods in the language service...
1254+
/// Calculates a hash code of method info. Must be compatible with ItemsAreEffectivelyEqual relation.
12551255
memberx.ComputeHashCode()=
12561256
match xwith
12571257
| ILMeth(_,x1,_)-> hash x1.RawMetadata.Name
@@ -1689,6 +1689,8 @@ type ILFieldInfo =
16891689
| ProvidedField(amap,fi,m)-> Import.ImportProvidedType amap m(fi.PApply((fun fi-> fi.FieldType),m))
16901690
#endif
16911691

1692+
/// Tests whether two infos have the same underlying definition.
1693+
/// Must be compatible with ItemsAreEffectivelyEqual relation.
16921694
static memberILFieldInfosUseIdenticalDefinitions x1 x2=
16931695
match x1,x2with
16941696
| ILFieldInfo(_, x1), ILFieldInfo(_, x2)->(x1=== x2)
@@ -1698,6 +1700,10 @@ type ILFieldInfo =
16981700
#endif
16991701
/// Get an (uninstantiated) reference to the field as an Abstract IL ILFieldRef
17001702
memberx.ILFieldRef= rescopeILFieldRef x.ScopeRef(mkILFieldRef(x.ILTypeRef,x.FieldName,x.ILFieldType))
1703+
1704+
/// Calculates a hash code of field info. Must be compatible with ItemsAreEffectivelyEqual relation.
1705+
memberx.ComputeHashCode()= hash x.FieldName
1706+
17011707
overridex.ToString()= x.FieldName
17021708

17031709

@@ -2156,8 +2162,8 @@ type PropInfo =
21562162
| FSProp_-> failwith"no setter method"
21572163

21582164
/// Test whether two property infos have the same underlying definition.
2159-
///
21602165
/// Uses the same techniques as 'MethInfosUseIdenticalDefinitions'.
2166+
/// Must be compatible with ItemsAreEffectivelyEqual relation.
21612167
static memberPropInfosUseIdenticalDefinitions x1 x2=
21622168
letoptVrefEq g=function
21632169
| Some(v1), Some(v2)-> valRefEq g v1 v2
@@ -2172,7 +2178,7 @@ type PropInfo =
21722178
#endif
21732179
|_->false
21742180

2175-
/// Calculates a hash code of property info (similar as previous)
2181+
/// Calculates a hash code of property info. Must be compatible with ItemsAreEffectivelyEqual relation.
21762182
memberpi.ComputeHashCode()=
21772183
match piwith
21782184
| ILProp ilpinfo-> hash ilpinfo.RawMetadata.Name
@@ -2411,6 +2417,7 @@ type EventInfo =
24112417

24122418

24132419
/// Test whether two event infos have the same underlying definition.
2420+
/// Must be compatible with ItemsAreEffectivelyEqual relation.
24142421
static memberEventInfosUseIdenticalDefintions x1 x2=
24152422
match x1, x2with
24162423
| FSEvent(g, pi1, vrefa1, vrefb1), FSEvent(_, pi2, vrefa2, vrefb2)->
@@ -2422,6 +2429,7 @@ type EventInfo =
24222429
|_->false
24232430

24242431
/// Calculates a hash code of event info (similar as previous)
2432+
/// Must be compatible with ItemsAreEffectivelyEqual relation.
24252433
memberei.ComputeHashCode()=
24262434
match eiwith
24272435
| ILEvent ileinfo-> hash ileinfo.RawMetadata.Name

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp