Optimize the config function to reduce the number of calls to config_p

When looking at a Performance Profile Index from NYTProf, we can see that the most called function is config_p, called mainly from the config function.

I think it is possible to improve the config function to reduce the number of calls to config_p.