[banshee] DapInfoBar: avoid accessing multiple times to same property



commit cc647ce2fc6e87df78e6bf71c3509d2aa9995929
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Tue Feb 18 16:58:56 2014 +0100

    DapInfoBar: avoid accessing multiple times to same property
    
    These DapSource properties could take a while to retrieve and
    they could be using locks (like in the case of MtpSource), so
    it's more efficient to read them just once.

 src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs 
b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
index 3b2e1f1..e372f87 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
@@ -137,13 +137,17 @@ namespace Banshee.Dap.Gui
 
         private void UpdateUsage ()
         {
-            long data = source.BytesUsed - source.BytesMusic - source.BytesVideo;
-            double cap = (double)source.BytesCapacity;
+            var bytes_used = source.BytesUsed;
+            var bytes_music = source.BytesMusic;
+            var bytes_video = source.BytesVideo;
+            var cap = (double)source.BytesCapacity;
 
-            disk_bar.UpdateSegment (0, source.BytesMusic / cap);
-            disk_bar.UpdateSegment (1, source.BytesVideo / cap);
+            long data = bytes_used - bytes_music - bytes_video;
+
+            disk_bar.UpdateSegment (0, bytes_music / cap);
+            disk_bar.UpdateSegment (1, bytes_video / cap);
             disk_bar.UpdateSegment (2, data / cap);
-            disk_bar.UpdateSegment (3, (cap - source.BytesUsed) / cap);
+            disk_bar.UpdateSegment (3, (cap - bytes_used) / cap);
         }
     }
 }


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