Bug 830975, make sure to flush all the documents, yet keep the no-flush-needed case fast, r=mccr8,f=bz,a=lsblakk

--HG--
extra : rebase_source : 08aee81e5a72026664ec3680b2e64dc219e43cb0