Optimization (outdated)

This change increased the build time by an order of magnitude on [one large site]. It was superseded by a simpler implementation.

See the new regression test for optimization.