Optimize pattern filling by limiting small calls to memcpy