From: Zeeshan Ali (Khattak) Date: Thu, 12 Nov 2009 14:35:17 +0000 (+0200) Subject: tracker: Get rid of one level of 'if' nesting X-Git-Tag: RYGEL_0_4_6~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0058631526d3e1f80d87d164f12358d491dd204;p=profile%2Fivi%2Frygel.git tracker: Get rid of one level of 'if' nesting This makes create_query_from_expression() a bit more readable. --- diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala index e4040aa..91eafc4 100644 --- a/src/plugins/tracker/rygel-tracker-search-container.vala +++ b/src/plugins/tracker/rygel-tracker-search-container.vala @@ -204,58 +204,62 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer { private string? create_query_from_expression (SearchExpression expression) { string query = null; - if (expression != null && expression is RelationalExpression) { - var rel_expression = expression as RelationalExpression; - if (rel_expression.operand1 == "@id") { - string parent_id; - string service; - - var path = this.get_item_info (rel_expression.operand2, - out parent_id, - out service); - if (path != null && parent_id != null && parent_id == this.id) { - var dir = Path.get_dirname (path); - var basename = Path.get_basename (path); - - var search_condition = + if (expression == null || !(expression is RelationalExpression)) { + return query; + } + + var rel_expression = expression as RelationalExpression; + if (rel_expression.operand1 == "@id") { + string parent_id; + string service; + + var path = this.get_item_info (rel_expression.operand2, + out parent_id, + out service); + if (path != null && parent_id != null && parent_id == this.id) { + var dir = Path.get_dirname (path); + var basename = Path.get_basename (path); + + var search_condition = "\n" + "\n" + "\n" + - "" + dir + - "\n" + + "" + + dir + + "\n" + "\n" + "\n" + "\n" + - "" + basename + - "\n" + + "" + + basename + + "\n" + "\n" + "\n"; - if (this.query_condition != "") { - query = "\n" + - "\n" + - search_condition + - this.query_condition + - "\n" + - ""; - } else { - query = "\n" + - search_condition + - ""; - } - } - } else if (rel_expression.operand1 == "@parentID" && - rel_expression.compare_string (this.id)) { if (this.query_condition != "") { query = "\n" + - this.query_condition + + "\n" + + search_condition + + this.query_condition + + "\n" + ""; } else { - query = ""; + query = "\n" + + search_condition + + ""; } } + } else if (rel_expression.operand1 == "@parentID" && + rel_expression.compare_string (this.id)) { + if (this.query_condition != "") { + query = "\n" + + this.query_condition + + ""; + } else { + query = ""; + } } return query;