implementation: Write lookup_combiner() in a less convoluted way.
authorSøren Sandmann Pedersen <ssp@redhat.com>
Sat, 15 Sep 2012 16:48:42 +0000 (12:48 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Wed, 19 Sep 2012 16:22:58 +0000 (12:22 -0400)
Instead of initializing an array on the stack, just use a simple
switch to select which set of combiners to look up in.

pixman/pixman-implementation.c

index 77d0906..d2573ab 100644 (file)
@@ -121,25 +121,36 @@ _pixman_implementation_lookup_combiner (pixman_implementation_t *imp,
                                        pixman_bool_t            component_alpha,
                                        pixman_bool_t            narrow)
 {
-    pixman_combine_32_func_t f;
-
-    do
+    while (imp)
     {
-       pixman_combine_32_func_t (*combiners[]) =
+       pixman_combine_32_func_t f = NULL;
+
+       switch ((narrow << 1) | component_alpha)
        {
-           (pixman_combine_32_func_t *)imp->combine_64,
-           (pixman_combine_32_func_t *)imp->combine_64_ca,
-           imp->combine_32,
-           imp->combine_32_ca,
-       };
+       case 0: /* not narrow, not component alpha */
+           f = (pixman_combine_32_func_t)imp->combine_64[op];
+           break;
+           
+       case 1: /* not narrow, component_alpha */
+           f = (pixman_combine_32_func_t)imp->combine_64_ca[op];
+           break;
+
+       case 2: /* narrow, not component alpha */
+           f = imp->combine_32[op];
+           break;
+
+       case 3: /* narrow, component_alpha */
+           f = imp->combine_32_ca[op];
+           break;
+       }
 
-       f = combiners[component_alpha | (narrow << 1)][op];
+       if (f)
+           return f;
 
        imp = imp->delegate;
     }
-    while (!f);
 
-    return f;
+    return NULL;
 }
 
 pixman_bool_t