On Fri. 15 janv. 2021 at 22:51, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote: > On 1/15/21 2:20 PM, Vincent MAILHOL wrote: > > /* map the data length to an appropriate data length code */ > > u8 can_fd_len2dlc(u8 len) > > { > > switch(len) { > > case 0 ... 8: > > return len; > > case 9 ... 12: > > return 9; > > case 13 ... 16: > > return 10; > > case 17 ... 20: > > return 11; > > case 21 ... 24: > > return 12; > > case 25 ... 32: > > return 13; > > case 33 ... 48: > > return 14; > > case 49 ... 64: > > default: > > return CANFD_MAX_DLC; > > } > > } > > > > And we will just leave the optimizations in the hand of the compiler. > > I've already tried this. It results in a longer object file on ARM, even if you > remove the array.... You are right. I just checked the assembly code: it does a dichotomy which means that in addition to being bigger, it is also slower. Please forget my previous message, it wasn't really smart. Yours sincerely, Vincent > Marc > > -- > Pengutronix e.K. | Marc Kleine-Budde | > Embedded Linux | https://www.pengutronix.de | > Vertretung West/Dortmund | Phone: +49-231-2826-924 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | >