Skip to content

Commit

Permalink
simplify _contentReadersCache check
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast committed May 12, 2024
1 parent 5fba42e commit 4894508
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/Xna.Framework.Content/Content/ContentTypeReaderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,19 @@ internal ContentTypeReader[] LoadAssetReaders(ContentReader reader, int typeRead
Type typeReaderType = ResolveReaderType(readerTypeName);
_contentTypeReadersCache.Add(readerTypeName, typeReaderType);

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

typeReader = typeReaderType.GetDefaultConstructor().Invoke(null) as ContentTypeReader;
needsInitialize[i] = true;
_contentReadersCache.Add(typeReaderType, typeReader);
}
else
{
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];
}
System.Diagnostics.Debug.Assert(_contentReadersCache.ContainsKey(typeReaderType));

typeReader = _contentReadersCache[typeReaderType];
}

if (readerTypeVersion != typeReader.TypeVersion)
Expand Down

0 comments on commit 4894508

Please sign in to comment.