[gegl] buffer: cache the vfunc in instance
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: cache the vfunc in instance
- Date: Sun, 3 Jul 2011 17:03:50 +0000 (UTC)
commit 6fde478a8c541555d08966ab3ca5065d6772cfc7
Author: Ãyvind KolÃs <pippin gimp org>
Date: Sun Jul 3 17:07:58 2011 +0100
buffer: cache the vfunc in instance
Slight speedup of sampler dispatch.
gegl/buffer/gegl-buffer.h | 1 +
gegl/buffer/gegl-sampler.c | 15 ++-------------
gegl/buffer/gegl-sampler.h | 10 ++++++++++
3 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index 78f76f6..58a37c4 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -382,6 +382,7 @@ GeglSampler *
gegl_buffer_sampler_new (GeglBuffer *buffer,
Babl *format,
GeglInterpolation interpolation);
+
void gegl_sampler_set_scale (GeglSampler *self,
GeglMatrix2 *scale);
void gegl_sampler_get (GeglSampler *self,
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 0e2b48b..b7d2676 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -122,18 +122,7 @@ gegl_sampler_get (GeglSampler *self,
GeglMatrix2 *scale,
void *output)
{
- GeglSamplerClass *klass;
-
-#if 0 /* avoiding expensive typecheck here */
- g_return_if_fail (GEGL_IS_SAMPLER (self));
-#endif
-
- self->x = x;
- self->y = y;
-
- klass = GEGL_SAMPLER_GET_CLASS (self); /*XXX: bottleneck, store the vfunc cached
- in the instance instead */
- klass->get (self, x, y, scale, output);
+ self->get (self, x, y, scale, output);
}
void
@@ -166,7 +155,7 @@ gegl_sampler_prepare (GeglSampler *self)
self->cache_buffer = NULL;
}
#endif
-
+ self->get = klass->get; /* cache the sampler in the instance */
}
void
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index 0fef155..78e2fe5 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -49,6 +49,16 @@ struct _GeglSampler
GeglRectangle sampler_rectangle[GEGL_SAMPLER_MIPMAP_LEVELS];
gdouble x; /* mirrors the currently requested */
gdouble y; /* coordinates in the instance */
+
+ /* we cache the getter in the instance, (being able to return the
+ function pointer itself and cache it outside the calling loop
+ would be even quicker.
+ */
+ void (* get) (GeglSampler *self,
+ gdouble x,
+ gdouble y,
+ GeglMatrix2 *scale,
+ void *output);
};
struct _GeglSamplerClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]