[12706] Small code optimizations. Thank to @tzurbaev

close issues/issues#422