Commit aac85619 authored by Mikhail I. Izmestev's avatar Mikhail I. Izmestev

cache fields for dia types

parent 2616b468
......@@ -207,7 +207,7 @@ TypeInfoPtr TypeFieldClangField::getTypeInfo()
///////////////////////////////////////////////////////////////////////////////
TypeInfoClangStruct::TypeInfoClangStruct(const std::wstring & name, ClangASTSessionPtr& session, clang::RecordDecl* decl) :
TypeInfoFields(name),
TypeInfoFields(name, L""),
m_astSession(session),
m_decl(decl)
{
......
......@@ -278,7 +278,7 @@ class TypeInfoClangEnum : public TypeInfoFields
public:
TypeInfoClangEnum(ClangASTSessionPtr& session, clang::EnumDecl* decl) :
TypeInfoFields(strToWStr(decl->getNameAsString())),
TypeInfoFields(strToWStr(decl->getNameAsString()), L""),
m_astSession(session),
m_decl(decl)
{}
......
......@@ -14,7 +14,7 @@ class CustomBase : public TypeInfoFields {
protected:
CustomBase( const std::wstring &name, size_t align ) :
TypeInfoFields(name)
TypeInfoFields(name, L"")
{
m_align = align ? align : ptrSize();
m_size = 0;
......
......@@ -322,7 +322,7 @@ public:
private:
NetTypeClass(COR_TYPEID& typeId, MetaDataProviderPtr& metaProvider, const std::wstring& name, mdTypeDef token) :
TypeInfoFields(name),
TypeInfoFields(name, L""),
m_typeId(typeId),
m_metaProvider(metaProvider),
m_name(name),
......
......@@ -1063,6 +1063,31 @@ size_t TypeInfoFields::getAlignReq()
return alignReq;
}
typedef std::map<std::pair<std::wstring, std::wstring>, FieldCollection> TypeInfoFieldsCache;
static TypeInfoFieldsCache fieldsCache;
void TypeInfoFields::checkFields()
{
if (!m_fieldsGot)
{
if (!m_scopeName.empty())
{
TypeInfoFieldsCache::key_type cacheKey(m_scopeName, m_name);
TypeInfoFieldsCache::iterator fields = fieldsCache.find(cacheKey);
if (fields != fieldsCache.end())
m_fields = fields->second;
else
{
getFields();
fieldsCache.insert(std::make_pair(cacheKey, m_fields));
}
}
else
getFields();
m_fieldsGot = true;
}
}
///////////////////////////////////////////////////////////////////////////////
void TypeInfoUdt::getVirtualDisplacement( const std::wstring& fieldName, MEMOFFSET_32 &virtualBasePtr, size_t &virtualDispIndex, size_t &virtualDispSize )
......
......@@ -348,15 +348,17 @@ protected:
protected:
TypeInfoFields( const std::wstring &name ) :
TypeInfoFields( const std::wstring &name, const std::wstring &scopeName ) :
m_fields( name ),
m_name( name ),
m_scopeName(scopeName),
m_fieldsGot(false)
{}
FieldCollection m_fields;
std::wstring m_name;
std::wstring m_scopeName;
virtual void getFields() = 0;
......@@ -364,15 +366,7 @@ private:
bool m_fieldsGot;
void checkFields()
{
if ( !m_fieldsGot )
{
getFields();
m_fieldsGot = true;
}
}
void checkFields();
};
///////////////////////////////////////////////////////////////////////////////
......@@ -381,7 +375,7 @@ class SymbolFields : public TypeInfoFields
{
public:
SymbolFields(SymbolPtr &symbol) :
TypeInfoFields( symbol->getName() ),
TypeInfoFields( symbol->getName(), symbol->getScopeName() ),
m_symbol(symbol)
{}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment