gegl r2675 - in trunk: . gegl/property-types
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2675 - in trunk: . gegl/property-types
- Date: Sat, 1 Nov 2008 15:56:29 +0000 (UTC)
Author: ok
Date: Sat Nov 1 15:56:29 2008
New Revision: 2675
URL: http://svn.gnome.org/viewvc/gegl?rev=2675&view=rev
Log:
* gegl/property-types/gegl-path.[ch]:
(gegl_path_is_empty): added a new call to quickly determine if there
are any control points in the path.
(ensure_tail): added caching code for the tail of the linked list
to avoid having to traverse it fully on each add.
(flatten_copy), (flatten_rel_copy), (gegl_path_list_append),
(gegl_path_clear), (gegl_path_remove), (gegl_path_replace),
(gegl_path_append),
(gegl_path_list_append_item): make use of the cache tail to speed up
instruction appends.
Modified:
trunk/ChangeLog
trunk/gegl/property-types/gegl-path.c
trunk/gegl/property-types/gegl-path.h
Modified: trunk/gegl/property-types/gegl-path.c
==============================================================================
--- trunk/gegl/property-types/gegl-path.c (original)
+++ trunk/gegl/property-types/gegl-path.c Sat Nov 1 15:56:29 2008
@@ -143,15 +143,16 @@
return;
}
-
static GeglPathList *
gegl_path_list_append_item (GeglPathList *head,
gchar type,
- GeglPathList **res)
+ GeglPathList **res,
+ GeglPathList *tail)
{
- GeglPathList *iter = head;
+ GeglPathList *iter = tail?tail:head;
InstructionInfo *info = lookup_instruction_info (type);
g_assert (info);
+
while (iter && iter->next)
iter=iter->next;
@@ -172,6 +173,7 @@
g_assert (res);
*res = iter;
+ tail = iter;
return head;
}
@@ -187,7 +189,7 @@
GeglPathList *self)
{
GeglPathList *newp;
- head = gegl_path_list_append_item (head, self->d.type, &newp);
+ head = gegl_path_list_append_item (head, self->d.type, &newp, NULL);
copy_data (&self->d, &newp->d);
return head;
}
@@ -199,7 +201,7 @@
{
GeglPathList *newp;
gint i;
- head = gegl_path_list_append_item (head, self->d.type, &newp);
+ head = gegl_path_list_append_item (head, self->d.type, &newp, NULL);
copy_data (&self->d, &newp->d);
for (i=0;i<4;i++)
{
@@ -332,7 +334,7 @@
if (!info)
g_error ("didn't find [%c]", type);
- head = gegl_path_list_append_item (head, type, &iter);
+ head = gegl_path_list_append_item (head, type, &iter, NULL);
iter->d.type = type;
for (pair_no=0;pair_no<info->pairs;pair_no++)
@@ -514,6 +516,7 @@
struct _GeglPathPrivate
{
GeglPathList *path;
+ GeglPathList *tail; /*< for fast appending */
GeglPathList *flat_path; /*< cache of flat path */
gboolean flat_path_clean;
GeglPath *parent_path;
@@ -525,6 +528,31 @@
GeglRectangle cached_extent;
};
+static GeglPathList *ensure_tail (GeglPathPrivate *priv)
+{
+ GeglPathList *tail_attempt = NULL;
+ GeglPathList *tail;
+
+ if (priv->tail)
+ {
+ for (tail_attempt=priv->tail;
+ tail_attempt && tail_attempt->next;
+ tail_attempt=tail_attempt->next);
+ return tail_attempt; /* comment his out, and
+ let failures be shown by
+ the assert below,.. */
+ }
+ for (tail=priv->tail;
+ tail && tail->next;
+ tail=tail->next);
+ if (tail_attempt)
+ {
+ g_assert (tail_attempt == tail);
+ }
+ priv->tail = tail;
+ return tail;
+}
+
enum
{
PROP_0,
@@ -987,6 +1015,7 @@
if (priv->path)
gegl_path_list_destroy (priv->path);
priv->path = NULL;
+ priv->tail = NULL;
}
void gegl_path_parse_string (GeglPath *vector,
@@ -1042,7 +1071,11 @@
}
}
-
+gboolean gegl_path_is_empty (GeglPath *path)
+{
+ GeglPathPrivate *priv = GEGL_PATH_GET_PRIVATE (path);
+ return priv->path != NULL;
+}
gint
gegl_path_get_count (GeglPath *vector)
@@ -1119,6 +1152,7 @@
gegl_path_item_free (prev);
}
priv->flat_path_clean = FALSE;
+ priv->tail = NULL;
gegl_path_emit_changed (vector, NULL);
}
@@ -1181,6 +1215,7 @@
/* check that it is large enough to contain us */
copy_data (knot, &iter->d);
priv->flat_path_clean = FALSE;
+ priv->tail = NULL;
gegl_path_emit_changed (vector, NULL);
return;
}
@@ -1271,7 +1306,7 @@
if (!info)
g_error ("didn't find [%c]", type);
- priv->path = gegl_path_list_append_item (priv->path, type, &iter);
+ priv->path = gegl_path_list_append_item (priv->path, type, &iter, ensure_tail(priv));
iter->d.type = type;
for (pair_no=0;pair_no<info->pairs;pair_no++)
Modified: trunk/gegl/property-types/gegl-path.h
==============================================================================
--- trunk/gegl/property-types/gegl-path.h (original)
+++ trunk/gegl/property-types/gegl-path.h Sat Nov 1 15:56:29 2008
@@ -63,7 +63,7 @@
GType gegl_path_get_type (void) G_GNUC_CONST;
GeglPath * gegl_path_new (void);
-
+gboolean gegl_path_is_empty (GeglPath *path);
void gegl_path_parse_string (GeglPath *path,
const gchar *path_string);
gchar * gegl_path_to_string (GeglPath *path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]