浏览代码

Check for ICollection to short-circuit.

Bart De Smet 7 年之前
父节点
当前提交
37d283ac3a
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs

@@ -274,7 +274,7 @@ namespace System.Linq
                     return count == -1 ? -1 : count + 1;
                 }
 
-                return !onlyIfCheap || _source is ICollection<TSource> ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + 1 : -1;
+                return !onlyIfCheap || _source is ICollection<TSource> || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + 1 : -1;
             }
         }
 
@@ -489,7 +489,7 @@ namespace System.Linq
                     return count == -1 ? -1 : count + _appendCount + _prependCount;
                 }
 
-                return !onlyIfCheap || _source is ICollection<TSource> ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1;
+                return !onlyIfCheap || _source is ICollection<TSource> || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1;
             }
         }
     }