Optimize `write_metadata`.
Optimize `write_metadata`.

`write_metadata` currently generates metadata unnecessarily in some
cases, and also compresses it unnecessarily in some cases. This commit
fixes that. It speeds up three of the rustc-benchmarks by 1--4%.

aidancully/rust,GBGamer/rust,graydon/rust,GBGamer/rust,aidancully/rust,GBGamer/rust,graydon/rust,graydon/rust,GBGamer/rust,aidancully/rust,GBGamer/rust,GBGamer/rust,aidancully/rust,aidancully/rust,GBGamer/rust,graydon/rust,aidancully/rust,graydon/rust,GBGamer/rust,graydon/rust