If you need the small size keep the 40.
The conventional wisdom back in the days of film was that if the FL difference was not by a factor of at least 20%, it was not worth owning a lens on the basis of FL alone. So other factors, like relative size/weight might make two similar FL lenses worth owning, as you might prefer size over other advantages at different times. Some of the other criteria worth pondering
- f/2 vs. f/2.8
- how much you prefer to use moderate wide 35mm FL over a more 'normal' FL (if FF)
- how much you prefer to use 'normal' 35mm FL over a short tele FL (if used on APS-C)
- if shooting video, STM better due to lower noise while focusing
- IS capable lens vs. not