Browse Source

Merge pull request #739 from danielcweber/CleanupMoreRedundancies

Cleanup more redundancies
Daniel C. Weber 7 năm trước cách đây
mục cha
commit
741b68a17b

+ 1 - 7
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs

@@ -396,8 +396,6 @@ namespace System.Reactive.Concurrency
 
                 while (true)
                 {
-                    var shouldWaitForResume = false;
-
                     lock (_gate)
                     {
                         if (_runState == RUNNING)
@@ -430,7 +428,6 @@ namespace System.Reactive.Concurrency
                         // will pick up the cumulative inactive time delta.
                         //
                         Debug.Assert(_runState == SUSPENDED);
-                        shouldWaitForResume = true;
                     }
 
                     //
@@ -440,10 +437,7 @@ namespace System.Reactive.Concurrency
                     // be extremely unlucky to find ourselves SUSPENDED again and be blocked
                     // once more.
                     //
-                    if (shouldWaitForResume)
-                    {
-                        _resumeEvent.WaitOne();
-                    }
+                    _resumeEvent.WaitOne();
                 }
 
                 recurse(this, next);

+ 1 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.cs

@@ -13,7 +13,7 @@ namespace System.Reactive.Concurrency
         internal static Type[] OPTIMIZATIONS = {
             typeof(ISchedulerLongRunning),
             typeof(IStopwatchProvider),
-            typeof(ISchedulerPeriodic),
+            typeof(ISchedulerPeriodic)
             /* update this list if new interface-based optimizations are added */
         };
 

+ 0 - 1
Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.cs

@@ -179,7 +179,6 @@ namespace System.Reactive.Linq.ObservableImpl
                         else if (_other.Done)
                         {
                             _parent.ForwardOnCompleted();
-                            return;
                         }
                     }
                 }

+ 8 - 36
Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs

@@ -392,12 +392,12 @@ namespace System.Reactive.Linq.ObservableImpl
                         return;
                     }
 
-                    try
+                    using (e)
                     {
                         var hasNext = true;
+
                         while (hasNext)
                         {
-                            hasNext = false;
                             var current = default(TResult);
 
                             try
@@ -420,13 +420,6 @@ namespace System.Reactive.Linq.ObservableImpl
                             }
                         }
                     }
-                    finally
-                    {
-                        if (e != null)
-                        {
-                            e.Dispose();
-                        }
-                    }
                 }
             }
         }
@@ -488,13 +481,13 @@ namespace System.Reactive.Linq.ObservableImpl
                         return;
                     }
 
-                    try
+                    using (e)
                     {
                         var eIndex = 0;
                         var hasNext = true;
+
                         while (hasNext)
                         {
-                            hasNext = false;
                             var current = default(TResult);
 
                             try
@@ -517,13 +510,6 @@ namespace System.Reactive.Linq.ObservableImpl
                             }
                         }
                     }
-                    finally
-                    {
-                        if (e != null)
-                        {
-                            e.Dispose();
-                        }
-                    }
                 }
             }
         }
@@ -1367,12 +1353,12 @@ namespace System.Reactive.Linq.ObservableImpl
                         return;
                     }
 
-                    try
+                    using (e)
                     {
                         var hasNext = true;
+
                         while (hasNext)
                         {
-                            hasNext = false;
                             var current = default(TResult);
 
                             try
@@ -1395,13 +1381,6 @@ namespace System.Reactive.Linq.ObservableImpl
                             }
                         }
                     }
-                    finally
-                    {
-                        if (e != null)
-                        {
-                            e.Dispose();
-                        }
-                    }
                 }
             }
         }
@@ -1457,12 +1436,12 @@ namespace System.Reactive.Linq.ObservableImpl
                         return;
                     }
 
-                    try
+                    using (e)
                     {
                         var hasNext = true;
+
                         while (hasNext)
                         {
-                            hasNext = false;
                             var current = default(TResult);
 
                             try
@@ -1485,13 +1464,6 @@ namespace System.Reactive.Linq.ObservableImpl
                             }
                         }
                     }
-                    finally
-                    {
-                        if (e != null)
-                        {
-                            e.Dispose();
-                        }
-                    }
                 }
             }
         }