Skip to content

Commit

Permalink
move _contentReadersCache
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast committed May 12, 2024
1 parent 9b03f1a commit 5fba42e
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,36 @@ internal ContentTypeReader[] LoadAssetReaders(ContentReader reader, int typeRead
int readerTypeVersion = reader.ReadInt32();

ContentTypeReader typeReader;
Type typeReaderType;
if (!_contentTypeReadersCache.ContainsKey(readerTypeName))
{
typeReaderType = ResolveReaderType(readerTypeName);
Type typeReaderType = ResolveReaderType(readerTypeName);
_contentTypeReadersCache.Add(readerTypeName, typeReaderType);
}
else
{
typeReaderType = _contentTypeReadersCache[readerTypeName];
}

if (!_contentReadersCache.ContainsKey(typeReaderType))
{
typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader;
needsInitialize[i] = true;
_contentReadersCache.Add(typeReaderType, typeReader);
if (!_contentReadersCache.ContainsKey(typeReaderType))
{
typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader;
needsInitialize[i] = true;
_contentReadersCache.Add(typeReaderType, typeReader);
}
else
{
typeReader = _contentReadersCache[typeReaderType];
}
}
else
{
typeReader = _contentReadersCache[typeReaderType];
Type typeReaderType = _contentTypeReadersCache[readerTypeName];

if (!_contentReadersCache.ContainsKey(typeReaderType))
{
typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader;
needsInitialize[i] = true;
_contentReadersCache.Add(typeReaderType, typeReader);
}
else
{
typeReader = _contentReadersCache[typeReaderType];
}
}

if (readerTypeVersion != typeReader.TypeVersion)
Expand Down

0 comments on commit 5fba42e

Please sign in to comment.