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

Lazify SourceFile::lines. #97575

Merged
merged 2 commits into from
Jun 2, 2022
Merged

Commits on Jun 1, 2022

  1. Lazify SourceFile::lines.

    `SourceFile::lines` is a big part of metadata. It's stored in a compressed form
    (a difference list) to save disk space. Decoding it is a big fraction of
    compile time for very small crates/programs.
    
    This commit introduces a new type `SourceFileLines` which has a `Lines`
    form and a `Diffs` form. The latter is used when the metadata is first
    read, and it is only decoded into the `Lines` form when line data is
    actually needed. This avoids the decoding cost for many files,
    especially in `std`. It's a performance win of up to 15% for tiny
    crates/programs where metadata decoding is a high part of compilation
    costs.
    
    A `Lock` is needed because the methods that access lines data (which can
    trigger decoding) take `&self` rather than `&mut self`. To allow for this,
    `SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather
    than returning the lines slice.
    nnethercote committed Jun 1, 2022
    Configuration menu
    Copy the full SHA
    0b81d7c View commit details
    Browse the repository at this point in the history

Commits on Jun 2, 2022

  1. Address review comments.

    nnethercote committed Jun 2, 2022
    Configuration menu
    Copy the full SHA
    72de7c4 View commit details
    Browse the repository at this point in the history