[tracker/tracker-0.8] libtracker-db: Avoid strstr in uri_is_parent and uri_is_descendant
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.8] libtracker-db: Avoid strstr in uri_is_parent and uri_is_descendant
- Date: Thu, 6 May 2010 17:54:54 +0000 (UTC)
commit 9817ee9dd2cd41d81677b56b0f767ef6da8ba333
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 ad0892c..2f48229 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -249,10 +249,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
@@ -319,12 +320,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]