diff options
| author | bors <bors@rust-lang.org> | 2020-09-18 21:31:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-18 21:31:08 +0000 |
| commit | bbc677480db8da85ea302e1e89d3df1f00e435bf (patch) | |
| tree | f11395b5d665ca39f61bef1a414b438ca170102e | |
| parent | 2cbc570e5814771a9b96db5c3d985b6452b59e80 (diff) | |
| parent | 2818032a2dee83b0b58318828e666e404838c8d9 (diff) | |
| download | rust-bbc677480db8da85ea302e1e89d3df1f00e435bf.tar.gz rust-bbc677480db8da85ea302e1e89d3df1f00e435bf.zip | |
Auto merge of #76782 - lzutao:rd-cap, r=jyn514
Specialize merge_attrs in good case Just a non-important micro-optimization. r? `@jyn514`
| -rw-r--r-- | src/librustdoc/clean/inline.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index f8987c6beca..a12181be67d 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -306,15 +306,17 @@ fn merge_attrs( attrs: Attrs<'_>, other_attrs: Option<Attrs<'_>>, ) -> clean::Attributes { - let mut merged_attrs: Vec<ast::Attribute> = Vec::with_capacity(attrs.len()); - // If we have additional attributes (from a re-export), + // NOTE: If we have additional attributes (from a re-export), // always insert them first. This ensure that re-export // doc comments show up before the original doc comments // when we render them. - if let Some(a) = other_attrs { - merged_attrs.extend(a.iter().cloned()); - } - merged_attrs.extend(attrs.to_vec()); + let merged_attrs = if let Some(inner) = other_attrs { + let mut both = inner.to_vec(); + both.extend_from_slice(attrs); + both + } else { + attrs.to_vec() + }; merged_attrs.clean(cx) } |
