Explorar o código

Remove more redundant assignments.

Bart De Smet %!s(int64=6) %!d(string=hai) anos
pai
achega
5faffd2edd

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

@@ -82,7 +82,7 @@ namespace System.Reactive.Concurrency
                 throw new ArgumentNullException(nameof(action));
                 throw new ArgumentNullException(nameof(action));
             }
             }
 
 
-            var queue = default(SchedulerQueue<TimeSpan>);
+            SchedulerQueue<TimeSpan> queue;
 
 
             // There is no timed task and no task is currently running
             // There is no timed task and no task is currently running
             if (!_running)
             if (!_running)

+ 1 - 2
Rx.NET/Source/src/System.Reactive/EventSource.cs

@@ -71,8 +71,7 @@ namespace System.Reactive
         {
         {
             lock (_subscriptions)
             lock (_subscriptions)
             {
             {
-                var l = new Stack<IDisposable>();
-                if (!_subscriptions.TryGetValue(handler, out l))
+                if (!_subscriptions.TryGetValue(handler, out var l))
                 {
                 {
                     _subscriptions[handler] = l = new Stack<IDisposable>();
                     _subscriptions[handler] = l = new Stack<IDisposable>();
                 }
                 }

+ 3 - 4
Rx.NET/Source/src/System.Reactive/Internal/ExceptionHelper.cs

@@ -69,14 +69,13 @@ namespace System.Reactive
                     return false;
                     return false;
                 }
                 }
 
 
-                var b = default(Exception);
+                Exception b;
 
 
                 if (current == null)
                 if (current == null)
                 {
                 {
                     b = ex;
                     b = ex;
                 }
                 }
-                else
-                if (current is AggregateException a)
+                else if (current is AggregateException a)
                 {
                 {
                     var list = new List<Exception>(a.InnerExceptions)
                     var list = new List<Exception>(a.InnerExceptions)
                     {
                     {
@@ -88,6 +87,7 @@ namespace System.Reactive
                 {
                 {
                     b = new AggregateException(current, ex);
                     b = new AggregateException(current, ex);
                 }
                 }
+
                 if (Interlocked.CompareExchange(ref field, b, current) == current)
                 if (Interlocked.CompareExchange(ref field, b, current) == current)
                 {
                 {
                     return true;
                     return true;
@@ -102,7 +102,6 @@ namespace System.Reactive
         {
         {
             internal TerminatedException() : base("No further exceptions")
             internal TerminatedException() : base("No further exceptions")
             {
             {
-
             }
             }
         }
         }
     }
     }

+ 1 - 1
Rx.NET/Source/src/System.Reactive/Internal/Helpers.cs

@@ -25,7 +25,7 @@ namespace System.Reactive
 
 
         public static IObservable<T> Unpack<T>(IObservable<T> source)
         public static IObservable<T> Unpack<T>(IObservable<T> source)
         {
         {
-            var hasOpt = default(bool);
+            bool hasOpt;
 
 
             do
             do
             {
             {

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

@@ -36,8 +36,8 @@ namespace System.Reactive.Linq.ObservableImpl
         protected override IDisposable Run(IObserver<T> observer)
         protected override IDisposable Run(IObserver<T> observer)
         {
         {
             var sourcesEnumerable = _sources;
             var sourcesEnumerable = _sources;
-            var sources = default(IObservable<T>[]);
 
 
+            IObservable<T>[] sources;
             try
             try
             {
             {
                 sources = sourcesEnumerable.ToArray();
                 sources = sourcesEnumerable.ToArray();

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

@@ -35,8 +35,9 @@ namespace System.Reactive.Linq.ObservableImpl
             public IAppendPrepend Append(TSource value)
             public IAppendPrepend Append(TSource value)
             {
             {
                 var prev = new Node<TSource>(_value);
                 var prev = new Node<TSource>(_value);
-                var appendNode = default(Node<TSource>);
-                var prependNode = default(Node<TSource>);
+
+                Node<TSource> appendNode;
+                Node<TSource> prependNode = null;
 
 
                 if (_append)
                 if (_append)
                 {
                 {
@@ -54,8 +55,9 @@ namespace System.Reactive.Linq.ObservableImpl
             public IAppendPrepend Prepend(TSource value)
             public IAppendPrepend Prepend(TSource value)
             {
             {
                 var prev = new Node<TSource>(_value);
                 var prev = new Node<TSource>(_value);
-                var appendNode = default(Node<TSource>);
-                var prependNode = default(Node<TSource>);
+
+                Node<TSource> appendNode = null;
+                Node<TSource> prependNode;
 
 
                 if (_append)
                 if (_append)
                 {
                 {

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

@@ -42,7 +42,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
 
             public void Run(Case<TValue, TResult> parent)
             public void Run(Case<TValue, TResult> parent)
             {
             {
-                var result = default(IObservable<TResult>);
+                IObservable<TResult> result;
                 try
                 try
                 {
                 {
                     result = parent.Eval();
                     result = parent.Eval();

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

@@ -37,7 +37,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
 
             public override void OnNext(TSource value)
             public override void OnNext(TSource value)
             {
             {
-                var res = false;
+                bool res;
                 try
                 try
                 {
                 {
                     res = _comparer.Equals(value, _value);
                     res = _comparer.Equals(value, _value);

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

@@ -327,7 +327,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
 
             private void AddHandler(TDelegate onNext)
             private void AddHandler(TDelegate onNext)
             {
             {
-                var removeHandler = default(IDisposable);
+                IDisposable removeHandler;
                 try
                 try
                 {
                 {
                     removeHandler = _parent.AddHandler(onNext);
                     removeHandler = _parent.AddHandler(onNext);

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

@@ -77,7 +77,7 @@ namespace System.Reactive.Linq.ObservableImpl
                 }
                 }
 
 
                 var fireNewMapEntry = false;
                 var fireNewMapEntry = false;
-                var writer = default(Subject<TElement>);
+                Subject<TElement> writer;
                 try
                 try
                 {
                 {
                     //
                     //

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

@@ -319,7 +319,7 @@ namespace System.Reactive.Linq.ObservableImpl
         {
         {
             added = false;
             added = false;
 
 
-            var value = default(TValue);
+            TValue value;
             var newValue = default(TValue);
             var newValue = default(TValue);
             var hasNewValue = false;
             var hasNewValue = false;
             while (true)
             while (true)

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

@@ -36,7 +36,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
 
             public void Run()
             public void Run()
             {
             {
-                var result = default(IObservable<TResult>);
+                IObservable<TResult> result;
                 try
                 try
                 {
                 {
                     result = _parent.Eval();
                     result = _parent.Eval();

+ 2 - 4
Rx.NET/Source/src/System.Reactive/Linq/Observable/Max.cs

@@ -46,8 +46,7 @@ namespace System.Reactive.Linq.ObservableImpl
             {
             {
                 if (_hasValue)
                 if (_hasValue)
                 {
                 {
-                    var comparison = 0;
-
+                    int comparison;
                     try
                     try
                     {
                     {
                         comparison = _comparer.Compare(value, _lastValue);
                         comparison = _comparer.Compare(value, _lastValue);
@@ -103,8 +102,7 @@ namespace System.Reactive.Linq.ObservableImpl
                     }
                     }
                     else
                     else
                     {
                     {
-                        var comparison = 0;
-
+                        int comparison;
                         try
                         try
                         {
                         {
                             comparison = _comparer.Compare(value, _lastValue);
                             comparison = _comparer.Compare(value, _lastValue);

+ 2 - 4
Rx.NET/Source/src/System.Reactive/Linq/Observable/Min.cs

@@ -46,8 +46,7 @@ namespace System.Reactive.Linq.ObservableImpl
             {
             {
                 if (_hasValue)
                 if (_hasValue)
                 {
                 {
-                    var comparison = 0;
-
+                    int comparison;
                     try
                     try
                     {
                     {
                         comparison = _comparer.Compare(value, _lastValue);
                         comparison = _comparer.Compare(value, _lastValue);
@@ -108,8 +107,7 @@ namespace System.Reactive.Linq.ObservableImpl
                     }
                     }
                     else
                     else
                     {
                     {
-                        var comparison = 0;
-
+                        int comparison;
                         try
                         try
                         {
                         {
                             comparison = _comparer.Compare(value, _lastValue);
                             comparison = _comparer.Compare(value, _lastValue);

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

@@ -381,7 +381,7 @@ namespace System.Reactive.Linq.ObservableImpl
                         return;
                         return;
                     }
                     }
 
 
-                    var e = default(IEnumerator<TCollection>);
+                    IEnumerator<TCollection> e;
                     try
                     try
                     {
                     {
                         e = xs.GetEnumerator();
                         e = xs.GetEnumerator();
@@ -470,7 +470,7 @@ namespace System.Reactive.Linq.ObservableImpl
                         return;
                         return;
                     }
                     }
 
 
-                    var e = default(IEnumerator<TCollection>);
+                    IEnumerator<TCollection> e;
                     try
                     try
                     {
                     {
                         e = xs.GetEnumerator();
                         e = xs.GetEnumerator();
@@ -1333,7 +1333,7 @@ namespace System.Reactive.Linq.ObservableImpl
                         return;
                         return;
                     }
                     }
 
 
-                    var e = default(IEnumerator<TResult>);
+                    IEnumerator<TResult> e;
                     try
                     try
                     {
                     {
                         e = xs.GetEnumerator();
                         e = xs.GetEnumerator();
@@ -1416,7 +1416,7 @@ namespace System.Reactive.Linq.ObservableImpl
                         return;
                         return;
                     }
                     }
 
 
-                    var e = default(IEnumerator<TResult>);
+                    IEnumerator<TResult> e;
                     try
                     try
                     {
                     {
                         e = xs.GetEnumerator();
                         e = xs.GetEnumerator();

+ 1 - 2
Rx.NET/Source/src/System.Reactive/Linq/Observable/SequenceEqual.cs

@@ -314,8 +314,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
 
                 public override void OnCompleted()
                 public override void OnCompleted()
                 {
                 {
-                    var hasNext = false;
-
+                    bool hasNext;
                     try
                     try
                     {
                     {
                         hasNext = _enumerator.MoveNext();
                         hasNext = _enumerator.MoveNext();

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

@@ -322,7 +322,7 @@ namespace System.Reactive.Linq.ObservableImpl
 
 
                 public override void OnNext(TFirst value)
                 public override void OnNext(TFirst value)
                 {
                 {
-                    var hasNext = false;
+                    bool hasNext;
                     try
                     try
                     {
                     {
                         hasNext = _rightEnumerator.MoveNext();
                         hasNext = _rightEnumerator.MoveNext();

+ 6 - 6
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Async.cs

@@ -670,7 +670,7 @@ namespace System.Reactive.Linq
 
 
         private IObservable<TSource> StartAsyncImpl<TSource>(Func<Task<TSource>> functionAsync, IScheduler scheduler)
         private IObservable<TSource> StartAsyncImpl<TSource>(Func<Task<TSource>> functionAsync, IScheduler scheduler)
         {
         {
-            var task = default(Task<TSource>);
+            Task<TSource> task;
             try
             try
             {
             {
                 task = functionAsync();
                 task = functionAsync();
@@ -702,7 +702,7 @@ namespace System.Reactive.Linq
         {
         {
             var cancellable = new CancellationDisposable();
             var cancellable = new CancellationDisposable();
 
 
-            var task = default(Task<TSource>);
+            Task<TSource> task;
             try
             try
             {
             {
                 task = functionAsync(cancellable.Token);
                 task = functionAsync(cancellable.Token);
@@ -712,7 +712,7 @@ namespace System.Reactive.Linq
                 return Throw<TSource>(exception);
                 return Throw<TSource>(exception);
             }
             }
 
 
-            var result = default(IObservable<TSource>);
+            IObservable<TSource> result;
 
 
             if (scheduler != null)
             if (scheduler != null)
             {
             {
@@ -773,7 +773,7 @@ namespace System.Reactive.Linq
 
 
         private IObservable<Unit> StartAsyncImpl(Func<Task> actionAsync, IScheduler scheduler)
         private IObservable<Unit> StartAsyncImpl(Func<Task> actionAsync, IScheduler scheduler)
         {
         {
-            var task = default(Task);
+            Task task;
             try
             try
             {
             {
                 task = actionAsync();
                 task = actionAsync();
@@ -805,7 +805,7 @@ namespace System.Reactive.Linq
         {
         {
             var cancellable = new CancellationDisposable();
             var cancellable = new CancellationDisposable();
 
 
-            var task = default(Task);
+            Task task;
             try
             try
             {
             {
                 task = actionAsync(cancellable.Token);
                 task = actionAsync(cancellable.Token);
@@ -815,7 +815,7 @@ namespace System.Reactive.Linq
                 return Throw<Unit>(exception);
                 return Throw<Unit>(exception);
             }
             }
 
 
-            var result = default(IObservable<Unit>);
+            IObservable<Unit> result;
 
 
             if (scheduler != null)
             if (scheduler != null)
             {
             {

+ 1 - 1
Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs

@@ -274,7 +274,7 @@ namespace System.Reactive.Subjects
                     break;
                     break;
                 }
                 }
 
 
-                var b = default(AsyncSubjectDisposable[]);
+                AsyncSubjectDisposable[] b;
                 if (n == 1)
                 if (n == 1)
                 {
                 {
                     b = Array.Empty<AsyncSubjectDisposable>();
                     b = Array.Empty<AsyncSubjectDisposable>();

+ 1 - 1
Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs

@@ -225,7 +225,7 @@ namespace System.Reactive.Subjects
                     break;
                     break;
                 }
                 }
 
 
-                var b = default(SubjectDisposable[]);
+                SubjectDisposable[] b;
                 if (n == 1)
                 if (n == 1)
                 {
                 {
                     b = Array.Empty<SubjectDisposable>();
                     b = Array.Empty<SubjectDisposable>();