buffer: cache the vfunc in instance

Slight speedup of sampler dispatch.
parent b30e5104
......@@ -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,
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment