浏览代码

Add performance remarks.

Bart De Smet 7 年之前
父节点
当前提交
65fd9d0201
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs

+ 8 - 0
Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs

@@ -8,6 +8,14 @@ using System.Threading.Tasks;
 
 namespace System.Linq
 {
+    // REVIEW: The base class below was introduced to avoid the overhead of storing a field of type TSource if the
+    //         value of the iterator can trivially be inferred from another field (e.g. in Repeat). It is also used
+    //         by the Defer operator in System.Interactive.Async. For some operators such as Where, Skip, Take, and
+    //         Concat, it could be used to retrieve the value from the underlying enumerator. However, performance
+    //         of this approach is a bit worse in some cases, so we don't go ahead with it for now. One decision to
+    //         make is whether it's okay for Current to throw an exception when MoveNextAsync returns false, e.g.
+    //         by omitting a null check for an enumerator field.
+
     internal abstract partial class AsyncIteratorBase<TSource> : IAsyncEnumerable<TSource>, IAsyncEnumerator<TSource>
     {
         private readonly int _threadId;