Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cheaper doc comments #65750

Merged
merged 2 commits into from
Nov 7, 2019
Merged

Commits on Nov 6, 2019

  1. Remove unnecessary Deref impl for Attribute.

    This kind of thing just makes the code harder to read.
    nnethercote committed Nov 6, 2019
    Configuration menu
    Copy the full SHA
    69bc4ab View commit details
    Browse the repository at this point in the history
  2. Make doc comments cheaper with AttrKind.

    `AttrKind` is a new type with two variants, `Normal` and `DocComment`. It's a
    big performance win (over 10% in some cases) because `DocComment` lets doc
    comments (which are common) be represented very cheaply.
    
    `Attribute` gets some new helper methods to ease the transition:
    - `has_name()`: check if the attribute name matches a single `Symbol`; for
      `DocComment` variants it succeeds if the symbol is `sym::doc`.
    - `is_doc_comment()`: check if it has a `DocComment` kind.
    - `{get,unwrap}_normal_item()`: extract the item from a `Normal` variant;
      panic otherwise.
    
    Fixes rust-lang#60935.
    nnethercote committed Nov 6, 2019
    Configuration menu
    Copy the full SHA
    eea6f23 View commit details
    Browse the repository at this point in the history