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

Commit5c4bf16

Browse files
committed
Don't create SymbolEnv repeatedly
1 parent66af44b commit5c4bf16

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

‎src/fsharp/fsi/fsi.fs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ type internal FsiDynamicCompiler
11671167
// Skip the "FSI_NNNN"
11681168
match contentFile.Declarationswith
11691169
|[FSharpImplementationFileDeclaration.Entity(_eFakeModule,modDecls)]->
1170+
letcenv= SymbolEnv(newState.tcGlobals, newState.tcState.Ccu, Some newState.tcState.CcuSig, newState.tcImports)
11701171
for declin modDeclsdo
11711172
match declwith
11721173
| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(v,_,_)->
@@ -1181,12 +1182,12 @@ type internal FsiDynamicCompiler
11811182
| None-> None
11821183
|_-> None
11831184

1184-
letsymbol= FSharpSymbol.Create(newState.tcGlobals, newState.tcState.Ccu, newState.tcState.CcuSig, newState.tcImports, v.Item)
1185+
letsymbol= FSharpSymbol.Create(cenv, v.Item)
11851186
letsymbolUse= FSharpSymbolUse(tcGlobals, newState.tcState.TcEnvFromImpls.DisplayEnv, symbol, ItemOccurence.Binding, v.DeclarationLocation)
11861187
fsi.TriggerEvaluation(fsiValueOpt, symbolUse, decl)
11871188
| FSharpImplementationFileDeclaration.Entity(e,_)->
11881189
// Report a top-level module or namespace definition
1189-
letsymbol= FSharpSymbol.Create(newState.tcGlobals, newState.tcState.Ccu, newState.tcState.CcuSig, newState.tcImports, e.Item)
1190+
letsymbol= FSharpSymbol.Create(cenv, e.Item)
11901191
letsymbolUse= FSharpSymbolUse(tcGlobals, newState.tcState.TcEnvFromImpls.DisplayEnv, symbol, ItemOccurence.Binding, e.DeclarationLocation)
11911192
fsi.TriggerEvaluation(None, symbolUse, decl)
11921193
| FSharpImplementationFileDeclaration.InitAction_->

‎src/fsharp/service/service.fs‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,10 @@ type TypeCheckInfo
937937
(fun()->
938938
match GetDeclItemsForNamesAtPosition(ctok, parseResultsOpt, Some partialName.QualifyingIdents, Some partialName.PartialIdent, partialName.LastDotPos, line, lineStr, partialName.EndColumn+1, ResolveTypeNamesToCtors, ResolveOverloads.Yes, getAllEntities, hasTextChangedSinceLastTypecheck)with
939939
| None-> FSharpDeclarationListInfo.Empty
940-
| Some(items, denv, ctx, m)->
940+
| Some(items, denv, ctx, m)->
941+
letcenv= SymbolEnv(g, thisCcu, Some ccuSigForFile, tcImports)
941942
letitems=if isInterfaceFilethen items|> List.filter(fun x-> IsValidSignatureFileItem x.Item)else items
942-
letgetAccessibility item= FSharpSymbol.GetAccessibility(FSharpSymbol.Create(g, thisCcu, ccuSigForFile, tcImports, item))
943+
letgetAccessibility item= FSharpSymbol.GetAccessibility(FSharpSymbol.Create(cenv, item))
943944
letcurrentNamespaceOrModule=
944945
parseResultsOpt
945946
|> Option.bind(fun x-> x.ParseTree)
@@ -1010,16 +1011,16 @@ type TypeCheckInfo
10101011

10111012
items|> List.filter(fun(nm,items)->not(isOpItem(nm,items))&&not(isFSharpList nm))
10121013

1013-
1014+
letcenv= SymbolEnv(g, thisCcu, Some ccuSigForFile, tcImports)
10141015
letitems=
10151016
// Filter out duplicate names
10161017
items|> List.map(fun(_nm,itemsWithSameName)->
10171018
match itemsWithSameNamewith
10181019
|[]-> failwith"Unexpected empty bag"
10191020
| items->
1020-
items
1021-
|> List.map(fun item->letsymbol= FSharpSymbol.Create(g, thisCcu, ccuSigForFile, tcImports, item.Item)
1022-
FSharpSymbolUse(g, denv, symbol, ItemOccurence.Use, m)))
1021+
items|> List.map(fun item->
1022+
letsymbol= FSharpSymbol.Create(cenv, item.Item)
1023+
FSharpSymbolUse(g, denv, symbol, ItemOccurence.Use, m)))
10231024

10241025
//end filtering
10251026
items)
@@ -1133,8 +1134,9 @@ type TypeCheckInfo
11331134
match GetDeclItemsForNamesAtPosition(ctok, None,Some(names), None, None,line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,(fun()->[]),fun _->false)with
11341135
| None| Some([],_,_,_)-> None
11351136
| Some(items, denv,_, m)->
1137+
letcenv= SymbolEnv(g, thisCcu, Some ccuSigForFile, tcImports)
11361138
letallItems= items|> List.collect(fun item-> SymbolHelpers.FlattenItems g m item.Item)
1137-
letsymbols= allItems|> List.map(fun item-> FSharpSymbol.Create(g, thisCcu, ccuSigForFile, tcImports, item))
1139+
letsymbols= allItems|> List.map(fun item-> FSharpSymbol.Create(cenv, item))
11381140
Some(symbols, denv, m)
11391141
)
11401142
(fun msg->
@@ -1887,11 +1889,12 @@ type FSharpCheckProjectResults(projectFileName:string, tcConfigOption, keepAssem
18871889
// Not, this does not have to be a SyncOp, it can be called from any thread
18881890
member__.GetAllUsesOfAllSymbols()=
18891891
let(tcGlobals,tcImports,thisCcu,ccuSig,tcSymbolUses,_topAttribs,_tcAssemblyData,_ilAssemRef,_ad,_tcAssemblyExpr,_dependencyFiles)= getDetails()
1892+
letcenv= SymbolEnv(tcGlobals, thisCcu, Some ccuSig, tcImports)
18901893

18911894
[|for rin tcSymbolUsesdo
18921895
for symbolUsein r.AllUsesOfSymbolsdo
18931896
if symbolUse.ItemOccurence<> ItemOccurence.RelatedTextthen
1894-
letsymbol= FSharpSymbol.Create(tcGlobals, thisCcu, ccuSig, tcImports, symbolUse.Item)
1897+
letsymbol= FSharpSymbol.Create(cenv, symbolUse.Item)
18951898
yield FSharpSymbolUse(tcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range)|]
18961899
|> async.Return
18971900

@@ -2079,11 +2082,12 @@ type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOp
20792082

20802083
memberinfo.GetAllUsesOfAllSymbolsInFile()=
20812084
threadSafeOp
2082-
(fun()->[||])
2083-
(fun scope->
2084-
[|for symbolUsein scope.ScopeSymbolUses.AllUsesOfSymbolsdo
2085-
if symbolUse.ItemOccurence<> ItemOccurence.RelatedTextthen
2086-
letsymbol= FSharpSymbol.Create(scope.TcGlobals, scope.ThisCcu, scope.CcuSigForFile, scope.TcImports, symbolUse.Item)
2085+
(fun()->[||])
2086+
(fun scope->
2087+
letcenv= SymbolEnv(scope.TcGlobals, scope.ThisCcu, Some scope.CcuSigForFile, scope.TcImports)
2088+
[|for symbolUsein scope.ScopeSymbolUses.AllUsesOfSymbolsdo
2089+
if symbolUse.ItemOccurence<> ItemOccurence.RelatedTextthen
2090+
letsymbol= FSharpSymbol.Create(cenv, symbolUse.Item)
20872091
yield FSharpSymbolUse(scope.TcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range)|])
20882092
|> async.Return
20892093

‎src/fsharp/symbols/Symbols.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ type FSharpSymbol(cenv: SymbolEnv, item: (unit -> Item), access: (FSharpSymbol -
229229
// TODO: there are several cases where we may need to report more interesting
230230
// symbol information below. By default we return a vanilla symbol.
231231
static memberCreate(g,thisCcu,thisCcuType,tcImports,item):FSharpSymbol=
232-
FSharpSymbol.Create(SymbolEnv(g, thisCcu, Some thisCcuType, tcImports), item)
232+
FSharpSymbol.Create(SymbolEnv(g, thisCcu, Some thisCcuType, tcImports), item)
233233

234234
static memberCreate(cenv,item):FSharpSymbol=
235235
letdflt()= FSharpSymbol(cenv,(fun()-> item),(fun _ _ _->true))

‎src/fsharp/symbols/Symbols.fsi‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ type [<Class>] public FSharpDisplayContext =
5050
/// FSharpField, FSharpGenericParameter, FSharpStaticParameter, FSharpMemberOrFunctionOrValue, FSharpParameter,
5151
/// or FSharpActivePatternCase.
5252
type[<Class>]public FSharpSymbol=
53-
/// Internal use only.
54-
static memberinternalCreate:g:TcGlobals* thisCcu: CcuThunk* thisCcuTyp: ModuleOrNamespaceType* tcImports: TcImports*item:NameResolution.Item-> FSharpSymbol
53+
static memberinternalCreate:g:TcGlobals* thisCcu: CcuThunk* thisCcuTyp: ModuleOrNamespaceType* tcImports: TcImports* item: NameResolution.Item-> FSharpSymbol
54+
static member internal Create: cenv: SymbolEnv*item:NameResolution.Item-> FSharpSymbol
5555

5656
/// Computes if the symbol is accessible for the given accessibility rights
5757
member IsAccessible: FSharpAccessibilityRights-> bool

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp