From cd26d44a6240bdbf7e7b039c4c13cf14dffa9e75 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 13 Feb 2020 07:54:06 -0800 Subject: [PATCH] Optimization to finding symbol references in file --- IDEHelper/Compiler/BfCompiler.cpp | 35 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index a32c720a..e14ccbd7 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -4109,6 +4109,23 @@ BfType* BfCompiler::CheckSymbolReferenceTypeRef(BfModule* module, BfTypeReferenc return resolvedType; } +void BfCompiler::AddToRebuildTypeList(BfTypeInstance* typeInst, HashSet& rebuildTypeInstList) +{ + if (mResolvePassData->mParser != NULL) + { + // Only find references within the current file + if (!typeInst->mTypeDef->HasSource(mResolvePassData->mParser)) + return; + } + + bool allowRebuild = ((!typeInst->IsGenericTypeInstance()) || + ((typeInst->IsUnspecializedType()) && (!typeInst->IsUnspecializedTypeVariation()))); + if ((typeInst->IsClosure()) || (typeInst->IsConcreteInterfaceType()) || (typeInst->IsRetTypeType())) + allowRebuild = false; + if (allowRebuild) + rebuildTypeInstList.Add(typeInst); +} + void BfCompiler::AddDepsToRebuildTypeList(BfTypeInstance* replaceTypeInst, HashSet& rebuildTypeInstList) { for (auto& dep : replaceTypeInst->mDependencyMap) @@ -4118,19 +4135,7 @@ void BfCompiler::AddDepsToRebuildTypeList(BfTypeInstance* replaceTypeInst, HashS if (depTypeInst == NULL) continue; - if (mResolvePassData->mParser != NULL) - { - // Only find references within the current file - if (!depTypeInst->mTypeDef->HasSource(mResolvePassData->mParser)) - continue; - } - - bool allowRebuild = ((!depTypeInst->IsGenericTypeInstance()) || - ((depTypeInst->IsUnspecializedType()) && (!depTypeInst->IsUnspecializedTypeVariation()))); - if ((depTypeInst->IsClosure()) || (depTypeInst->IsConcreteInterfaceType()) || (depTypeInst->IsRetTypeType())) - allowRebuild = false; - if (allowRebuild) - rebuildTypeInstList.Add(depTypeInst); + AddToRebuildTypeList(depTypeInst, rebuildTypeInstList); } } @@ -4173,8 +4178,8 @@ void BfCompiler::GetSymbolReferences() } } } - - rebuildTypeInstList.Add(replaceTypeInst); + + AddToRebuildTypeList(replaceTypeInst, rebuildTypeInstList); //TODO: Did we need this to be rebuildTypeInst->mModule??? Why? //auto rebuildModule = rebuildTypeInst->mModule;