Improve memory performance when generating config static and class caches

Improves #1705 

Final xhprof benchmarking:

<table >
<tr><th></th><th>Run #51da7bfa0e9b0</th><th>Run #51da7be07d1a1</th><th>Diff</th><th>Diff%</th></tr><tr><td>Number of Function Calls</td><td>3,418,925</td>
<td>3,126,772</td>
<td>-292,153</td>
<td>-8.5%</td>
</tr><tr><td>Incl. Wall Time (microsec)</td><td>9,809,302</td>
<td>8,829,096</td>
<td>-980,206</td>
<td>-10.0%</td>
</tr><tr></tr><tr><td>Incl. CPU (microsecs)</td><td>9,794,225</td>
<td>8,732,070</td>
<td>-1,062,155</td>
<td>-10.8%</td>
</tr><tr></tr><tr><td>Incl. MemUse (bytes)</td><td>25,068,840</td>
<td>25,057,480</td>
<td>-11,360</td>
<td>-0.0%</td>
</tr><tr></tr><tr><td>Incl.  PeakMemUse (bytes)</td><td>57,953,040</td>
<td>25,264,256</td>
<td>-32,688,784</td>
<td>-56.4%</td>
</tr></table>