goffice r2123 - in trunk: . goffice/app
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: goffice r2123 - in trunk: . goffice/app
- Date: Mon, 23 Jun 2008 20:23:09 +0000 (UTC)
Author: mortenw
Date: Mon Jun 23 20:23:09 2008
New Revision: 2123
URL: http://svn.gnome.org/viewvc/goffice?rev=2123&view=rev
Log:
2008-06-23 Morten Welinder <terra gnome org>
* goffice/app/go-doc.c (go_doc_add_image): Rewrite to avoid
GHashTableIter.
Modified:
trunk/ChangeLog
trunk/goffice/app/go-doc.c
Modified: trunk/goffice/app/go-doc.c
==============================================================================
--- trunk/goffice/app/go-doc.c (original)
+++ trunk/goffice/app/go-doc.c Mon Jun 23 20:23:09 2008
@@ -292,23 +292,42 @@
NULL;
}
+struct check_for_pixbuf {
+ GOImage *src_image;
+ GOImage *dst_image;
+};
+
+static void
+check_for_pixbuf (gpointer key, gpointer img_, gpointer user)
+{
+ GOImage *img = img_;
+ struct check_for_pixbuf *cl = user;
+
+ if (cl->dst_image == NULL) {
+ if (go_image_same_pixbuf (cl->src_image, img))
+ cl->dst_image = img;
+ }
+}
+
GOImage *
go_doc_add_image (GODoc *doc, char const *id, GOImage *image)
{
- GHashTableIter iter;
- char const *key;
GOImage *img;
int i = 0;
char *new_id;
+ struct check_for_pixbuf cl;
if (doc->images == NULL)
doc->images = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
+
/* check if the image is already there */
- g_hash_table_iter_init (&iter, doc->images);
- while (g_hash_table_iter_next (&iter, (void**) &key, (void**) &img))
- if (go_image_same_pixbuf (image, img))
- return img;
+ cl.src_image = image;
+ cl.dst_image = NULL;
+ g_hash_table_foreach (doc->images, check_for_pixbuf, &img);
+ if (cl.dst_image)
+ return cl.dst_image;
+
/* now check if the id is not a duplicate */
if (g_hash_table_lookup (doc->images, id)) {
while (1) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]