Both calibers are effective at both barrel lengths, but you give up muzzle velocity and sight radius as you shorten the barrel. Frankly, there's not that much difference between the two barrel lengths. It would be more pronounced in comparing a 5 inch and 3 inch barrel.
Sight radius will be an issue with both barrel lengths independent of caliber. Even in the more drastic 5" v 3" comparison though it's less of an issue within the close contact distances that a personal defense gun would be used. It makes a difference, but the shorter sight radius is more important at longer distances.
The velocity give up is more important in my view, but only for the .45 in my view. The .40 sw is a high velocity round and expansion of self defense ammunition is not an issue in the shorter barrels. It's my view, and there is a lot of debate on this, that the shorter 3" barrels create some question of hp expansion. He round is subsonic to begin with and generally slows down by 100 ft/sec for every inch off the barrel. I have a 4" self defense weapon in .45 and a 5" competition gun. The 4" barrel is as short as I will go with a .45. Again, plenty of others like the 3" barrel and that's fine too.
So, long winded answer, but I don't think barrel length will matter much for either caliber unless the difference in barrel length was more drastic, and even then it's only the .45 that would really be affected. Hope this is helpful.