[epiphany/wip/ephy-sync: 114/126] bookmarks-manager: Manually iterate over sequence when searching by id
- From: Gabriel - Cristian Ivascu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/ephy-sync: 114/126] bookmarks-manager: Manually iterate over sequence when searching by id
- Date: Fri, 19 Aug 2016 17:41:08 +0000 (UTC)
commit 0c07d0c255405d152f0ba1e0ee8228b52bc10ef7
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Tue Aug 9 13:29:02 2016 +0300
bookmarks-manager: Manually iterate over sequence when searching by id
src/ephy-bookmarks-manager.c | 27 ++++++++-------------------
1 files changed, 8 insertions(+), 19 deletions(-)
---
diff --git a/src/ephy-bookmarks-manager.c b/src/ephy-bookmarks-manager.c
index 986ab95..5d801c0 100644
--- a/src/ephy-bookmarks-manager.c
+++ b/src/ephy-bookmarks-manager.c
@@ -363,18 +363,6 @@ ephy_bookmarks_manager_get_bookmark_by_url (EphyBookmarksManager *self,
return NULL;
}
-static int
-bookmark_with_id_compare (gpointer *ebookmark,
- gconstpointer id)
-{
- EphyBookmark *bookmark = EPHY_BOOKMARK (ebookmark);
- const char *bookmark_id;
-
- bookmark_id = ephy_bookmark_get_id (bookmark);
-
- return g_strcmp0 (bookmark_id, id);
-}
-
EphyBookmark *
ephy_bookmarks_manager_get_bookmark_by_id (EphyBookmarksManager *self,
const char *id)
@@ -384,15 +372,16 @@ ephy_bookmarks_manager_get_bookmark_by_id (EphyBookmarksManager *self,
g_return_val_if_fail (EPHY_IS_BOOKMARKS_MANAGER (self), FALSE);
g_return_val_if_fail (id != NULL, FALSE);
- iter = g_sequence_lookup (self->bookmarks,
- (gpointer)id,
- (GCompareDataFunc)bookmark_with_id_compare,
- NULL);
+ for (iter = g_sequence_get_begin_iter (self->bookmarks);
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter)) {
+ EphyBookmark *bookmark = g_sequence_get (iter);
- if (iter == NULL)
- return NULL;
+ if (g_strcmp0 (ephy_bookmark_get_id (bookmark), id) == 0)
+ return bookmark;
+ }
- return g_sequence_get (iter);
+ return NULL;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]