[WIP] Mapgen performance improvements

Fixes #8743 
I'd rather you not typedef like this, the only effect is to obscure what's happening.