internal: Optimize apply_document_changes
a bit
#13547
Merged
apply_document_changes
a bit
#13547