improve the performance of the vec![] macro

Closes #17865