Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
By default Swift-DocC writes all files to disk atomically. This is generally a good default since it can prevent confusing errors. When writing atomically, the file will first be written to a temp location and then, only when the writing is complete, copied into the final destination. This means that if writing fails halfway through, there won't be a malformed file in the destination. If the file is there at all, it's correct. However, for writing RenderJSON from `docc convert` specifically, this is unnecessary for a couple of reasons. 1. The `docc convert` process never reads RenderJSON, only writes it. 2. `docc convert` already writes _all_ of its output to a temp directory and only copies it over to the final destination if the entire conversion ran without errors. So in the event that a RenderJSON write _does_ fail halfway through, we still end up with the desired behavior of not having malformed JSON in the target destination. An error would be thrown and the conversion would fail without copying any of the bad output from the temp directory. As it stands `docc convert` effectively implements atomic writes twice. The reason to _not_ write RenderJSON atomically is performance. By writing non-atomically there's an ~8% performance win for the "documentation-processing" step of the conversion process.
- Loading branch information