mirror of https://github.com/astral-sh/ruff
refactor: Avoid some unnecessary allocations
This commit is contained in:
parent
6fc6bf0648
commit
4dcb491bec
|
|
@ -127,10 +127,10 @@ impl Settings {
|
||||||
pub fn from_configuration(config: Configuration, project_root: &Path) -> Result<Self> {
|
pub fn from_configuration(config: Configuration, project_root: &Path) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
rules: build_rule_table(
|
rules: build_rule_table(
|
||||||
config.fixable,
|
&config.fixable,
|
||||||
config.unfixable,
|
&config.unfixable,
|
||||||
config.select,
|
&config.select,
|
||||||
config.ignore,
|
&config.ignore,
|
||||||
&config.extend_select,
|
&config.extend_select,
|
||||||
&config.extend_ignore,
|
&config.extend_ignore,
|
||||||
&config.pydocstyle,
|
&config.pydocstyle,
|
||||||
|
|
@ -240,10 +240,10 @@ impl Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_rule_table(
|
fn build_rule_table(
|
||||||
fixable: Option<Vec<RuleSelector>>,
|
fixable: &Option<Vec<RuleSelector>>,
|
||||||
unfixable: Option<Vec<RuleSelector>>,
|
unfixable: &Option<Vec<RuleSelector>>,
|
||||||
select: Option<Vec<RuleSelector>>,
|
select: &Option<Vec<RuleSelector>>,
|
||||||
ignore: Option<Vec<RuleSelector>>,
|
ignore: &Option<Vec<RuleSelector>>,
|
||||||
extend_select: &[Vec<RuleSelector>],
|
extend_select: &[Vec<RuleSelector>],
|
||||||
extend_ignore: &[Vec<RuleSelector>],
|
extend_ignore: &[Vec<RuleSelector>],
|
||||||
pydocstyle: &Option<pydocstyle::settings::Options>,
|
pydocstyle: &Option<pydocstyle::settings::Options>,
|
||||||
|
|
@ -251,14 +251,14 @@ fn build_rule_table(
|
||||||
let mut rules = RuleTable::empty();
|
let mut rules = RuleTable::empty();
|
||||||
|
|
||||||
let fixable = resolve_codes([RuleCodeSpec {
|
let fixable = resolve_codes([RuleCodeSpec {
|
||||||
select: &fixable.unwrap_or_else(|| CATEGORIES.to_vec()),
|
select: fixable.as_deref().unwrap_or(CATEGORIES),
|
||||||
ignore: &unfixable.unwrap_or_default(),
|
ignore: unfixable.as_deref().unwrap_or_default(),
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
for code in validate_enabled(resolve_codes(
|
for code in validate_enabled(resolve_codes(
|
||||||
[RuleCodeSpec {
|
[RuleCodeSpec {
|
||||||
select: &select.unwrap_or_else(|| defaults::PREFIXES.to_vec()),
|
select: select.as_deref().unwrap_or(defaults::PREFIXES),
|
||||||
ignore: &ignore.unwrap_or_default(),
|
ignore: ignore.as_deref().unwrap_or_default(),
|
||||||
}]
|
}]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(
|
.chain(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue