summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-inheritance.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-05-29 18:01:11 -0700
committerGitHub <noreply@github.com>2024-05-29 18:01:11 -0700
commitefdbb954c57b89362e390f955d45f90e59d66878 (patch)
tree7b47d6e52d2de666af99f66a2fd3a5dc387ca5cc /source/slang/slang-check-inheritance.cpp
parent83f176ba8a3bae5533470aed6a90663653f894b8 (diff)
Improve compile time performance. (#3857)
* Handle type check cache update on extensions more gracefully. * Correctness fix. * Cache implcit cast overload resolution results. * Fix. * More optimizations. * Cache implicit default ctor resolution. * Disable redundancy removal. * Fix. * Fix test. * Fix. * Correctness fix. * Fix. * Fix, * Fix test. * Small tweak.
Diffstat (limited to 'source/slang/slang-check-inheritance.cpp')
-rw-r--r--source/slang/slang-check-inheritance.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/slang/slang-check-inheritance.cpp b/source/slang/slang-check-inheritance.cpp
index 18624424c..f1dbaef5c 100644
--- a/source/slang/slang-check-inheritance.cpp
+++ b/source/slang/slang-check-inheritance.cpp
@@ -5,11 +5,6 @@
// related to computing linearized inheritance
// information for types and decalrations.
-//#include "slang-lookup.h"
-//#include "slang-syntax.h"
-//#include "slang-ast-synthesis.h"
-//#include <limits>
-
namespace Slang
{
InheritanceInfo SharedSemanticsContext::getInheritanceInfo(Type* type)
@@ -17,7 +12,12 @@ namespace Slang
// We cache the computed inheritance information for types,
// and re-use that information whenever possible.
- if(auto found = m_mapTypeToInheritanceInfo.tryGetValue(type))
+ // DeclRefTypes will have their inheritance info cached in m_mapDeclRefToInheritanceInfo.
+ if (auto declRefType = as<DeclRefType>(type))
+ return _getInheritanceInfo(declRefType->getDeclRef(), declRefType);
+
+ // Non ordinary types are cached on m_mapTypeToInheritanceInfo.
+ if (auto found = m_mapTypeToInheritanceInfo.tryGetValue(type))
return *found;
// Note: we install a null pointer into the dictionary to act
@@ -32,9 +32,6 @@ namespace Slang
auto info = _calcInheritanceInfo(type);
m_mapTypeToInheritanceInfo[type] = info;
- getSession()->m_typeDictionarySize = Math::Max(
- getSession()->m_typeDictionarySize, (int)m_mapTypeToInheritanceInfo.getCount());
-
return info;
}
@@ -68,6 +65,9 @@ namespace Slang
auto info = _calcInheritanceInfo(declRef, declRefType);
m_mapDeclRefToInheritanceInfo[declRef] = info;
+ getSession()->m_typeDictionarySize = Math::Max(
+ getSession()->m_typeDictionarySize, (int)m_mapDeclRefToInheritanceInfo.getCount());
+
return info;
}