dri: Simplify use of driConcatConfigs

If either argument to driConcatConfigs(a, b) is null or the empty list,
then simply return the other argument as the resultant list.

All callers were accomplishing that same behavior anyway. And each caller
accopmplished it with the same pattern. So this patch moves that external
pattern into the function.

Reviewed-by: <eric@anholt.net>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
This commit is contained in:
Chad Versace 2012-08-01 21:23:47 -07:00
parent b2d428cb8d
commit a4bf68ca50
5 changed files with 13 additions and 22 deletions

View file

@ -219,16 +219,12 @@ dri_fill_in_modes(struct dri_screen *screen,
if (pixel_bits == 16) {
configs = configs_r5g6b5;
if (configs_a8r8g8b8)
configs = configs ? driConcatConfigs(configs, configs_a8r8g8b8) : configs_a8r8g8b8;
if (configs_x8r8g8b8)
configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
configs = driConcatConfigs(configs, configs_a8r8g8b8);
configs = driConcatConfigs(configs, configs_x8r8g8b8);
} else {
configs = configs_a8r8g8b8;
if (configs_x8r8g8b8)
configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
if (configs_r5g6b5)
configs = configs ? driConcatConfigs(configs, configs_r5g6b5) : configs_r5g6b5;
configs = driConcatConfigs(configs, configs_x8r8g8b8);
configs = driConcatConfigs(configs, configs_r5g6b5);
}
if (configs == NULL) {

View file

@ -409,6 +409,11 @@ __DRIconfig **driConcatConfigs(__DRIconfig **a,
__DRIconfig **all;
int i, j, index;
if (a == NULL || a[0] == NULL)
return b;
else if (b == NULL || b[0] == NULL)
return a;
i = 0;
while (a[i] != NULL)
i++;

View file

@ -878,10 +878,7 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
msaa_samples_array,
ARRAY_SIZE(msaa_samples_array),
false);
if (configs == NULL)
configs = new_configs;
else
configs = driConcatConfigs(configs, new_configs);
configs = driConcatConfigs(configs, new_configs);
}
/* Generate the minimum possible set of configs that include an
@ -903,10 +900,7 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
back_buffer_modes + 1, 1,
msaa_samples_array, 1,
true);
if (configs == NULL)
configs = new_configs;
else
configs = driConcatConfigs(configs, new_configs);
configs = driConcatConfigs(configs, new_configs);
}
if (configs == NULL) {

View file

@ -79,8 +79,7 @@ nouveau_get_configs(void)
GL_TRUE);
assert(config);
configs = configs ? driConcatConfigs(configs, config)
: config;
configs = driConcatConfigs(configs, config);
}
return (const __DRIconfig **)configs;

View file

@ -760,10 +760,7 @@ __DRIconfig **radeonInitScreen2(__DRIscreen *psp)
msaa_samples_array,
ARRAY_SIZE(msaa_samples_array),
GL_TRUE);
if (configs == NULL)
configs = new_configs;
else
configs = driConcatConfigs(configs, new_configs);
configs = driConcatConfigs(configs, new_configs);
}
if (configs == NULL) {