ruff/crates/ruff_cli
Charlie Marsh 2aeb27334d
Avoid cloning source code multiple times (#6629)
## Summary

In working on https://github.com/astral-sh/ruff/pull/6628, I noticed
that we clone the source code contents, potentially multiple times,
prior to linting. The issue is that `SourceKind::Python` takes a
`String`, so we first have to provide it with a `String`. In the stdin
case, that means cloning. However, on top of this, we then have to clone
`source_kind.contents()` because `SourceKind` gets mutated. So for
stdin, we end up cloning twice. For non-stdin, we end up cloning once,
but unnecessarily (since the _contents_ don't get mutated, only the
kind).

This PR removes the `String` from `source_kind`, instead requiring that
we parse it out elsewhere. It reduces the number of clones down to 1 for
Jupyter Notebooks, and zero otherwise.
2023-08-18 09:32:18 -04:00
..
resources/test/fixtures Include file permissions in key for cached files (#5901) 2023-07-25 17:06:47 +00:00
src Avoid cloning source code multiple times (#6629) 2023-08-18 09:32:18 -04:00
tests Respect .ipynb and .pyi sources when linting from stdin (#6628) 2023-08-16 20:33:59 +00:00
Cargo.toml Bump version to 0.0.285 (#6660) 2023-08-17 15:46:28 -05:00