[rygel: 3/6] server: Coding style fix - early exit



commit 40ecb640052ed25918f59be1087ca05c9425aa76
Author: Jens Georg <jensg openismus com>
Date:   Thu Jan 3 12:30:51 2013 +0100

    server: Coding style fix - early exit

 src/librygel-server/rygel-http-item-uri.vala |   82 +++++++++++++-------------
 1 files changed, 42 insertions(+), 40 deletions(-)
---
diff --git a/src/librygel-server/rygel-http-item-uri.vala b/src/librygel-server/rygel-http-item-uri.vala
index dc98e0d..ab764e1 100644
--- a/src/librygel-server/rygel-http-item-uri.vala
+++ b/src/librygel-server/rygel-http-item-uri.vala
@@ -62,58 +62,60 @@ internal class Rygel.HTTPItemURI : Object {
         this.playlist_format = playlist_format;
         this.extension = "";
 
-        if (object is MediaItem) {
-            var item = object as MediaItem;
-            if (thumbnail_index > -1) {
-                if (item is VisualItem) {
-                    var thumbnails = (item as VisualItem).thumbnails;
-
-                    if (thumbnails.size > thumbnail_index) {
-                        this.extension = thumbnails[thumbnail_index].file_extension;
-                    }
-                } else if (item is MusicItem) {
-                    var album_art = (item as MusicItem).album_art;
-
-                    if (album_art != null) {
-                        this.extension = album_art.file_extension;
-                    }
+        if (!(object is MediaItem)) {
+            return;
+        }
+
+        var item = object as MediaItem;
+        if (thumbnail_index > -1) {
+            if (item is VisualItem) {
+                var thumbnails = (item as VisualItem).thumbnails;
+
+                if (thumbnails.size > thumbnail_index) {
+                    this.extension = thumbnails[thumbnail_index].file_extension;
                 }
-            } else if (subtitle_index > -1) {
-                if (item is VideoItem) {
-                    var subtitles = (item as VideoItem).subtitles;
+            } else if (item is MusicItem) {
+                var album_art = (item as MusicItem).album_art;
 
-                    if (subtitles.size > subtitle_index) {
-                        this.extension = subtitles[subtitle_index].caption_type;
-                    }
+                if (album_art != null) {
+                    this.extension = album_art.file_extension;
                 }
-            } else if (transcode_target != null) {
-                try {
-                    var tc = this.http_server.get_transcoder (transcode_target);
+            }
+        } else if (subtitle_index > -1) {
+            if (item is VideoItem) {
+                var subtitles = (item as VideoItem).subtitles;
 
-                    this.extension = tc.extension;
-                } catch (Error error) {}
+                if (subtitles.size > subtitle_index) {
+                    this.extension = subtitles[subtitle_index].caption_type;
+                }
             }
+        } else if (transcode_target != null) {
+            try {
+                var tc = this.http_server.get_transcoder (transcode_target);
 
-            if (this.extension == "") {
-                string uri_extension = "";
+                this.extension = tc.extension;
+            } catch (Error error) {}
+        }
 
-                foreach (string uri_string in item.uris) {
-                    string basename = Path.get_basename (uri_string);
-                    int dot_index = basename.last_index_of(".");
+        if (this.extension == "") {
+            string uri_extension = "";
 
-                    if (dot_index > -1) {
-                        uri_extension = basename.substring (dot_index + 1);
+            foreach (string uri_string in item.uris) {
+                string basename = Path.get_basename (uri_string);
+                int dot_index = basename.last_index_of(".");
 
-                        break;
-                    }
-                }
+                if (dot_index > -1) {
+                    uri_extension = basename.substring (dot_index + 1);
 
-                if (uri_extension == "") {
-                    this.extension = this.ext_from_mime_type (item.mime_type);
-                } else {
-                    this.extension = uri_extension;
+                    break;
                 }
             }
+
+            if (uri_extension == "") {
+                this.extension = this.ext_from_mime_type (item.mime_type);
+            } else {
+                this.extension = uri_extension;
+            }
         }
     }
 


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