[tracker/rss-enclosures] libtracker-db: Avoid strstr in uri_is_parent and uri_is_descendant



commit b1b9315d4b07a9cd0263ed0bdab0dd40b5555c50
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Apr 29 23:21:51 2010 +0200

    libtracker-db: Avoid strstr in uri_is_parent and uri_is_descendant

 src/libtracker-db/tracker-db-interface-sqlite.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index b39dba2..507448c 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -250,10 +250,11 @@ function_sparql_uri_is_parent (sqlite3_context *context,
 	 * be compared with the other anyway.
 	 */
 
-	if (!(parent_len >= 7 && (parent[4] == ':' && parent[5] == '/' && parent[6] == '/')) ||
-	    strstr (parent, "://") == NULL) {
-		sqlite3_result_int (context, FALSE);
-		return;
+	if (!(parent_len >= 7 && (parent[4] == ':' || parent[5] == '/' || parent[6] == '/'))) {
+		if (strstr (parent, "://") == NULL) {
+			sqlite3_result_int (context, FALSE);
+			return;
+		}
 	}
 
 	/* Remove trailing '/', will
@@ -320,12 +321,13 @@ function_sparql_uri_is_descendant (sqlite3_context *context,
 	/* Check only one argument, it's going to
 	 * be compared with the other anyway.
 	 */
-	if (!(parent_len >= 7 && (parent[4] == ':' && parent[5] == '/' && parent[6] == '/')) ||
-	    strstr (parent, "://") == NULL) {
-		sqlite3_result_int (context, FALSE);
-		return;
-	}
 
+	if (!(parent_len >= 7 && (parent[4] == ':' || parent[5] == '/' || parent[6] == '/'))) {
+		if (strstr (parent, "://") == NULL) {
+			sqlite3_result_int (context, FALSE);
+			return;
+		}
+	}
 
 	/* Remove trailing '/', will
 	 * be checked later on uri.



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