Преглед изворни кода

Optimizing layout of DefaultIfEmpty.

Bart De Smet пре 8 година
родитељ
комит
73d9a3d6ed
1 измењених фајлова са 6 додато и 6 уклоњено
  1. 6 6
      Rx.NET/Source/src/System.Reactive/Linq/Observable/DefaultIfEmpty.cs

+ 6 - 6
Rx.NET/Source/src/System.Reactive/Linq/Observable/DefaultIfEmpty.cs

@@ -17,20 +17,20 @@ namespace System.Reactive.Linq.ObservableImpl
 
         protected override IDisposable Run(IObserver<TSource> observer, IDisposable cancel, Action<IDisposable> setSink)
         {
-            var sink = new _(this, observer, cancel);
+            var sink = new _(_defaultValue, observer, cancel);
             setSink(sink);
             return _source.SubscribeSafe(sink);
         }
 
-        class _ : Sink<TSource>, IObserver<TSource>
+        private sealed class _ : Sink<TSource>, IObserver<TSource>
         {
-            private readonly DefaultIfEmpty<TSource> _parent;
+            private readonly TSource _defaultValue;
             private bool _found;
 
-            public _(DefaultIfEmpty<TSource> parent, IObserver<TSource> observer, IDisposable cancel)
+            public _(TSource defaultValue, IObserver<TSource> observer, IDisposable cancel)
                 : base(observer, cancel)
             {
-                _parent = parent;
+                _defaultValue = defaultValue;
                 _found = false;
             }
 
@@ -49,7 +49,7 @@ namespace System.Reactive.Linq.ObservableImpl
             public void OnCompleted()
             {
                 if (!_found)
-                    base._observer.OnNext(_parent._defaultValue);
+                    base._observer.OnNext(_defaultValue);
                 base._observer.OnCompleted();
                 base.Dispose();
             }