will it make sense do define that as typed array and move along with templateX, templateY to the parent scope (or at least cache it there) to stress GC less?