Skip to content

Remove unused dead code in BamlMapTable / XamlTypeMapper #10881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -348,53 +348,6 @@ private static Type GetKnownConverterTypeFromPropName(
#region Methods

#if !PBTCOMPILER
// This is called when a parse is begun when the very first baml record is
// processed. If the BamlMapTable already contains data, then this means
// it is being re-used for multiple parses. In this case set the _reusingMapTable
// flag and make certain that the ObjectHashTable is populated before clearing
// the existing assembly, type and property lists for the next parse.
internal void Initialize()
{
if (AttributeIdMap.Count > 0 || TypeIdMap.Count > 0)
{
_reusingMapTable = true;
// Populate the ObjectHashTable here only after the first parse has
// completed and the second is about to begin. This is done so that
// a single parse does not pay the price of having the hash table, and
// the second through 'n' parses are added as they are read in.
if (ObjectHashTable.Count == 0)
{
// Loop through attributes. We only care about having CLR properties in
// the hash table. DependencyProperties are already cached by the framework.
for (int i = 0; i < AttributeIdMap.Count; i++)
{
BamlAttributeInfoRecord info = AttributeIdMap[i];
if (info.PropInfo != null)
{
object key = GetAttributeInfoKey(info.OwnerType.FullName, info.Name);
ObjectHashTable.Add(key, info);
}
}

// Loop through types and cache them.
for (int j = 0; j < TypeIdMap.Count; j++)
{
BamlTypeInfoRecord info = TypeIdMap[j];
if (info.Type != null)
{
BamlAssemblyInfoRecord assyInfo = GetAssemblyInfoFromId(info.AssemblyId);
TypeInfoKey key = GetTypeInfoKey(assyInfo.AssemblyFullName, info.TypeFullName);
ObjectHashTable.Add(key, info);
}
}
}
}
AssemblyIdMap.Clear();
TypeIdMap.Clear();
AttributeIdMap.Clear();
StringIdMap.Clear();
}

// Given an Id looks up the Type in the MapTable. This works for known types
// and types that are a part of BamlTypeInfoRecords in the baml file.
internal Type GetTypeFromId(short id)
Expand Down Expand Up @@ -767,7 +720,6 @@ internal Type GetTypeFromTypeInfo(BamlTypeInfoRecord typeInfo)
{
Type type = assembly.GetType(typeInfo.TypeFullName);
typeInfo.Type = type;
AddHashTableData(key, typeInfo);
}
}
}
Expand Down Expand Up @@ -1662,19 +1614,6 @@ internal Object GetHashTableData(object key)
return ObjectHashTable[key];
}

#if !PBTCOMPILER
// Add item to the hash table. Only do this if the map table
// is being re-used for multiple parses. Otherwise the hash table
// data is of no use for a single parse.
internal void AddHashTableData(object key, object data)
{
if (_reusingMapTable)
{
ObjectHashTable[key] = data;
}
}
#endif

#if !PBTCOMPILER
internal BamlMapTable Clone() => new BamlMapTable(_xamlTypeMapper)
{
Expand Down Expand Up @@ -1842,13 +1781,6 @@ private Hashtable ConverterCache
private Hashtable _converterCache = null;
#endif

#if !PBTCOMPILER
// True if this instance of the BamlMapTable is being reused between
// different parses. This is done to maintain the ObjectHashTable so that
// less reflection is done for types and properties.
private bool _reusingMapTable = false;
#endif

#endregion Data

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ protected internal BamlRecordReader()
/// </summary>
internal void Initialize()
{
MapTable.Initialize();
XamlTypeMapper.Initialize();
ParserContext.Initialize();
}
Expand Down
Loading