[gegl] sampler: do fewer lookups of klass->get



commit a459312ff9281fc0314136cc7497f17413068923
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jul 9 17:55:10 2014 +0200

    sampler: do fewer lookups of klass->get

 gegl/buffer/gegl-sampler.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 0e02c0c..0631df1 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -72,6 +72,8 @@ static void buffer_contents_changed (GeglBuffer          *buffer,
                                      const GeglRectangle *changed_rect,
                                      gpointer             userdata);
 
+static void constructed (GObject *sampler);
+
 static GType gegl_sampler_gtype_from_enum  (GeglSamplerType      sampler_type);
 
 G_DEFINE_TYPE (GeglSampler, gegl_sampler, G_TYPE_OBJECT)
@@ -83,6 +85,7 @@ gegl_sampler_class_init (GeglSamplerClass *klass)
 
   object_class->finalize = finalize;
   object_class->dispose  = dispose;
+  object_class->constructed  = constructed;
 
   klass->prepare    = NULL;
   klass->get        = NULL;
@@ -136,6 +139,14 @@ gegl_sampler_init (GeglSampler *sampler)
                GEGL_SAMPLER_MAXIMUM_HEIGHT * GEGL_SAMPLER_BPP);
 }
 
+static void
+constructed (GObject *self)
+{
+  GeglSampler *sampler = (void*)(self);
+  GeglSamplerClass *klass = GEGL_SAMPLER_GET_CLASS (sampler);
+  sampler->get = klass->get;
+}
+
 void
 gegl_sampler_get (GeglSampler     *self,
                   gdouble          x,
@@ -174,11 +185,9 @@ gegl_sampler_prepare (GeglSampler *self)
   if (!self->format)
     self->format = self->buffer->soft_format;
 
-  self->get = klass->get; /* cache the sampler in the instance */
-  /* migh be overridden by samplers prepare*/
   if (klass->prepare)
     klass->prepare (self);
-
+  
   if (!self->fish)
     self->fish = babl_fish (self->interpolate_format, self->format);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]