From f0a9cca06cffa42a88ef20f80004ed99609efee1 Mon Sep 17 00:00:00 2001 From: Peter Harvey Date: Sat, 4 Feb 2006 09:16:25 +0000 Subject: src/bookmarks/ephy-bookmarks.c 2006-02-04 Peter Harvey * src/bookmarks/ephy-bookmarks.c Improve code quality of function to determine similar bookmarks. --- ChangeLog | 6 ++++++ src/bookmarks/ephy-bookmarks.c | 37 +++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index e45ef60b4..06ee364e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-02-04 Peter Harvey + + * src/bookmarks/ephy-bookmarks.c + + Improve code quality of function to determine similar bookmarks. + 2006-02-03 Christian Persch * src/ephy-main.c: (main): diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 36a3455d5..35c9e7eab 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -1189,26 +1189,23 @@ ephy_bookmarks_find_bookmark (EphyBookmarks *eb, static gboolean is_similar (const char *url1, const char *url2) { - while(*url1 == *url2 && *url1 != '\0' && - *url1 != '#' && *url1 != '?') - { - url1++; - url2++; - } - if(*url1 == *url2) return TRUE; - if(*url1 == '\0') - { - if(*url2 == '#') return TRUE; - if(*url2 == '?') return TRUE; - if(*url2 == '/' && *(url2+1) == '\0') return TRUE; - } - if(*url2 == '\0') - { - if(*url1 == '#') return TRUE; - if(*url1 == '?') return TRUE; - if(*url1 == '/' && *(url1+1) == '\0') return TRUE; - } - return FALSE; + int i, j; + + for (i = 0; url1[i]; i++) + if (url1[i] == '#' || url1[i] == '?') + break; + while(i>0 && url1[i] == '/') + i--; + + for (j = 0; url2[j]; j++) + if (url2[j] == '#' || url2[j] == '?') + break; + while(j>0 && url2[j] == '/') + j--; + + if (i != j) return FALSE; + if (strncmp (url1, url2, i) != 0) return FALSE; + return TRUE; } gint -- cgit v1.2.3