Code performance fix related to #3185