aaubry/YamlDotNet — pull request #116 by jeffman (2014-12-26 03:09:34+00:00)
Title: Anchor assignment

I noticed that assigning node anchors can be extremely slow for large `YamlDocument`s; for example, writing a ~5.3 MB YAML file takes about 28 minutes, and the vast majority of that time is taken from assigning node anchors.

If I know ahead of time that my document does not contain any cross-references, then I can safely skip the anchor assignment and the output will be unaffected. This brought the writing time down from 28 minutes to 4 seconds for that 5.3 MB file.

This change adds an overload to `YamlStream.Save()` which allows the user to enable (or disable/skip) anchor assignment. This defaults to `true` (which is the current behaviour and which makes this a non-breaking change), but it can be changed to `false` to skip anchor assignment and consequently save lots of time.

The user would only need to be aware that explicitly using the overload with `false` would cause cross-referenced nodes to be emitted independently, which may or may not be desirable based on their requirements.