sortify on-demand
A simple throttling mechanism was already implemented where only the last of a series of synchronous local changes would actually trigger serialization. This patch improves that optimization to precompute a conditional expression that could never change at runtime, and to avoid precomputing and expensive operation until the final serialization. This seems to make a significant improvement for documents which contain large maps, particularly in circumstances where many successive changes could occur synchronously.