[rygel] server: Small code simplification



commit 2e65748ed178fefebe29318265e9ac72d62a2d2c
Author: Jens Georg <mail jensge org>
Date:   Sun Jan 12 19:50:48 2020 +0100

    server: Small code simplification
    
    Early exist can save one level of indentation

 src/librygel-server/rygel-visual-item.vala | 56 ++++++++++++++++--------------
 1 file changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/src/librygel-server/rygel-visual-item.vala b/src/librygel-server/rygel-visual-item.vala
index f3e4a27d..edb3e87e 100644
--- a/src/librygel-server/rygel-visual-item.vala
+++ b/src/librygel-server/rygel-visual-item.vala
@@ -78,37 +78,39 @@ public interface Rygel.VisualItem : MediaFileItem {
     }
 
     internal void add_thumbnail_resources (HTTPServer http_server) {
+        if (this.place_holder) {
+            return;
+        }
+
         for (var i = 0; i < this.thumbnails.size; i++) {
-            if (!this.place_holder) {
-                var thumbnail = this.thumbnails.get (i);
-                // Add the defined thumbnail uri unconditionally
-                //  (it will be filtered out if the request is remote)
-                string protocol;
-                try {
-                    protocol = this.get_protocol_for_uri (thumbnail.uri);
-                } catch (Error e) {
-                    message (/*_*/("Could not determine protocol for URI %s"),
-                             thumbnail.uri);
+            var thumbnail = this.thumbnails.get (i);
+            // Add the defined thumbnail uri unconditionally
+            //  (it will be filtered out if the request is remote)
+            string protocol;
+            try {
+                protocol = this.get_protocol_for_uri (thumbnail.uri);
+            } catch (Error e) {
+                message (/*_*/("Could not determine protocol for URI %s"),
+                         thumbnail.uri);
 
-                    continue;
-                }
+                continue;
+            }
 
-                var thumb_res = thumbnail.get_resource (protocol, i);
-                thumb_res.uri = thumbnail.uri;
-                this.get_resource_list ().add (thumb_res);
-                if (http_server.need_proxy (thumbnail.uri)) {
-                    var http_thumb_res = thumbnail.get_resource
-                                        (http_server.get_protocol (), i);
+            var thumb_res = thumbnail.get_resource (protocol, i);
+            thumb_res.uri = thumbnail.uri;
+            this.get_resource_list ().add (thumb_res);
+            if (http_server.need_proxy (thumbnail.uri)) {
+                var http_thumb_res = thumbnail.get_resource
+                                    (http_server.get_protocol (), i);
 
-                    var index = this.thumbnails.index_of (thumbnail);
-                    // Make a http uri for the thumbnail
-                    http_thumb_res.uri = http_server.create_uri_for_object
-                                                 (this,
-                                                  index,
-                                                  -1,
-                                                  null);
-                    this.get_resource_list ().add (http_thumb_res);
-                }
+                var index = this.thumbnails.index_of (thumbnail);
+                // Make a http uri for the thumbnail
+                http_thumb_res.uri = http_server.create_uri_for_object
+                                             (this,
+                                              index,
+                                              -1,
+                                              null);
+                this.get_resource_list ().add (http_thumb_res);
             }
         }
     }


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