Remove unneeded casts to IDisposable and ConcurrentDictionary

Commit migrated from https://github.com/dotnet/corefx/commit/fa6e6a1e6300cdbffa31998a8c70d3bb9b7d06c3
This commit is contained in:
James Ko committed 2015-08-07 13:05:11 -04:00
1 parent def1bb72b5
commit da459a135f
5 files changed
+17 -13

No files matched your search

@@ -1359,7 +1359,7 @@ namespace System.Collections.Concurrent
{
if (key == null) throw new ArgumentNullException("key");
return (key is TKey) && ((ConcurrentDictionary<TKey, TValue>)this).ContainsKey((TKey)key);
return (key is TKey) && this.ContainsKey((TKey)key);
}
/// <summary>Provides an <see cref="T:System.Collections.Generics.IDictionaryEnumerator"/> for the
@@ -16,7 +16,7 @@ namespace System.IO
public static SyncTextReader GetSynchronizedTextReader(TextReader reader)
{
Debug.Assert(reader != null);
return reader as SyncTextReader ??
return reader as SyncTextReader ??
new SyncTextReader(reader);
}
@@ -31,8 +31,7 @@ namespace System.IO
{
lock (_methodLock)
{
// Explicitly pick up a potentially methodimpl'ed Dispose
((IDisposable)_in).Dispose();
_in.Dispose();
}
}
}
@@ -87,7 +86,7 @@ namespace System.IO
//
// On SyncTextReader all APIs should run synchronously, even the async ones.
// No explicit locking is needed, as they all just delegate
// No explicit locking is needed, as they all just delegate
//
public override Task<String> ReadLineAsync()
@@ -15,7 +15,7 @@ namespace System.IO
internal static SyncTextWriter GetSynchronizedTextWriter(TextWriter writer)
{
Debug.Assert(writer != null);
return writer as SyncTextWriter ??
return writer as SyncTextWriter ??
new SyncTextWriter(writer);
}
@@ -47,8 +47,7 @@ namespace System.IO
{
lock (_methodLock)
{
// Explicitly pick up a potentially methodimpl'ed Dispose
((IDisposable)_out).Dispose();
_out.Dispose();
}
}
}
@@ -184,8 +184,11 @@ namespace System.Linq
public override void Dispose()
{
if (_enumerator is IDisposable) ((IDisposable)_enumerator).Dispose();
_enumerator = null;
if (_enumerator != null)
{
_enumerator.Dispose();
_enumerator = null;
}
base.Dispose();
}
@@ -347,8 +350,11 @@ namespace System.Linq
public override void Dispose()
{
if (_enumerator is IDisposable) ((IDisposable)_enumerator).Dispose();
_enumerator = null;
if (_enumerator != null)
{
_enumerator.Dispose();
_enumerator = null;
}
base.Dispose();
}
@@ -197,7 +197,7 @@ namespace System.Xml
{
if (disposing)
{
((IDisposable)writer).Dispose();
writer.Dispose();
}
}
}