[banshee] Lastfm: refactor to avoid duplicated if-else block



commit 467947d81b20246c71d5eda90ef1215049b9a7cc
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Sat Mar 16 21:20:53 2013 +0000

    Lastfm: refactor to avoid duplicated if-else block
    
    After previous commit, this state assignment became duplicated between
    the two blocks of the if-else statement. Also, use the ? operator so it
    is less verbose.
    
    No change of behaviour in this commit.

 .../Lastfm/Lastfm/AudioscrobblerConnection.cs      |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs 
b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
index dcad888..3e685a6 100644
--- a/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
+++ b/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
@@ -313,26 +313,16 @@ namespace Lastfm
                 // we succeeded, pop the elements off our queue
                 queue.RemoveRange (0, nb_tracks_scrobbled);
                 queue.Save ();
-
-                if (queue.Count > 0) {
-                    state = State.NeedTransmit;
-                } else {
-                    state = State.Idle;
-                }
             } else {
                 // TODO: If error == StationError.InvalidSessionKey,
                 // suggest to the user to (re)do the Last.fm authentication.
                 hard_failures++;
 
                 queue.RemoveInvalidTracks ();
-
-                // if there are still valid tracks in the queue then retransmit on the next interval
-                if (queue.Count > 0) {
-                    state = State.NeedTransmit;
-                } else {
-                    state = State.Idle;
-                }
             }
+
+            // if there are still valid tracks in the queue then retransmit on the next interval
+            state = queue.Count > 0 ? State.NeedTransmit : State.Idle;
         }
 
         private void LogIfIgnored (JsonObject scrobbled_track)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]