Re #10430. Some performance improvements.

In the test that I run the speed up is about 3 times.
Merge remote-tracking branch 'origin/feature/10430_sxdmdnorm_performance'