mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 10:02:38 +03:00
Remove lots of unnecessary clones (thanks clippy!)
This commit is contained in:
parent
72706a0ac0
commit
a4338f0406
@ -358,8 +358,8 @@ pub fn sort_can_defs(
|
||||
let mut defined_symbols_set: ImSet<Symbol> = ImSet::default();
|
||||
|
||||
for symbol in can_defs_by_symbol.keys().into_iter() {
|
||||
defined_symbols.push(symbol.clone());
|
||||
defined_symbols_set.insert(symbol.clone());
|
||||
defined_symbols.push(*symbol);
|
||||
defined_symbols_set.insert(*symbol);
|
||||
}
|
||||
|
||||
// Use topological sort to reorder the defs based on their dependencies to one another.
|
||||
@ -688,7 +688,7 @@ fn pattern_to_vars_by_symbol(
|
||||
use Pattern::*;
|
||||
match pattern {
|
||||
Identifier(symbol) => {
|
||||
vars_by_symbol.insert(symbol.clone(), expr_var);
|
||||
vars_by_symbol.insert(*symbol, expr_var);
|
||||
}
|
||||
|
||||
AppliedTag { arguments, .. } => {
|
||||
@ -699,7 +699,7 @@ fn pattern_to_vars_by_symbol(
|
||||
|
||||
RecordDestructure { destructs, .. } => {
|
||||
for destruct in destructs {
|
||||
vars_by_symbol.insert(destruct.value.symbol.clone(), destruct.value.var);
|
||||
vars_by_symbol.insert(destruct.value.symbol, destruct.value.var);
|
||||
}
|
||||
}
|
||||
|
||||
@ -947,7 +947,7 @@ fn canonicalize_pending_def<'a>(
|
||||
) = (
|
||||
&loc_pattern.value,
|
||||
&loc_can_pattern.value,
|
||||
&loc_can_expr.value.clone(),
|
||||
&loc_can_expr.value,
|
||||
) {
|
||||
is_closure = true;
|
||||
|
||||
@ -964,7 +964,7 @@ fn canonicalize_pending_def<'a>(
|
||||
// closures don't have a name, and therefore pick a fresh symbol. But in this
|
||||
// case, the closure has a proper name (e.g. `foo` in `foo = \x y -> ...`
|
||||
// and we want to reference it by that name.
|
||||
env.closures.insert(defined_symbol.clone(), references);
|
||||
env.closures.insert(*defined_symbol, references);
|
||||
|
||||
// The closure is self tail recursive iff it tail calls itself (by defined name).
|
||||
let is_recursive = match can_output.tail_call {
|
||||
@ -975,7 +975,7 @@ fn canonicalize_pending_def<'a>(
|
||||
// Recursion doesn't count as referencing. (If it did, all recursive functions
|
||||
// would result in circular def errors!)
|
||||
refs_by_symbol
|
||||
.entry(defined_symbol.clone())
|
||||
.entry(*defined_symbol)
|
||||
.and_modify(|(_, refs)| {
|
||||
refs.lookups = refs.lookups.without(defined_symbol);
|
||||
});
|
||||
@ -1008,7 +1008,7 @@ fn canonicalize_pending_def<'a>(
|
||||
};
|
||||
|
||||
refs_by_symbol.insert(
|
||||
symbol.clone(),
|
||||
*symbol,
|
||||
(
|
||||
Located {
|
||||
value: ident.clone(),
|
||||
@ -1055,7 +1055,7 @@ fn canonicalize_pending_def<'a>(
|
||||
env.tailcallable_symbol = Some(*defined_symbol);
|
||||
|
||||
// TODO isn't types_by_symbol enough? Do we need vars_by_symbol too?
|
||||
vars_by_symbol.insert(defined_symbol.clone(), expr_var);
|
||||
vars_by_symbol.insert(*defined_symbol, expr_var);
|
||||
};
|
||||
|
||||
let (mut loc_can_expr, can_output) =
|
||||
@ -1080,7 +1080,7 @@ fn canonicalize_pending_def<'a>(
|
||||
) = (
|
||||
&loc_pattern.value,
|
||||
&loc_can_pattern.value,
|
||||
&loc_can_expr.value.clone(),
|
||||
&loc_can_expr.value,
|
||||
) {
|
||||
is_closure = true;
|
||||
|
||||
@ -1097,7 +1097,7 @@ fn canonicalize_pending_def<'a>(
|
||||
// closures don't have a name, and therefore pick a fresh symbol. But in this
|
||||
// case, the closure has a proper name (e.g. `foo` in `foo = \x y -> ...`
|
||||
// and we want to reference it by that name.
|
||||
env.closures.insert(defined_symbol.clone(), references);
|
||||
env.closures.insert(*defined_symbol, references);
|
||||
|
||||
// The closure is self tail recursive iff it tail calls itself (by defined name).
|
||||
let is_recursive = match can_output.tail_call {
|
||||
@ -1108,7 +1108,7 @@ fn canonicalize_pending_def<'a>(
|
||||
// Recursion doesn't count as referencing. (If it did, all recursive functions
|
||||
// would result in circular def errors!)
|
||||
refs_by_symbol
|
||||
.entry(defined_symbol.clone())
|
||||
.entry(*defined_symbol)
|
||||
.and_modify(|(_, refs)| {
|
||||
refs.lookups = refs.lookups.without(defined_symbol);
|
||||
});
|
||||
@ -1145,7 +1145,7 @@ fn canonicalize_pending_def<'a>(
|
||||
});
|
||||
|
||||
refs_by_symbol.insert(
|
||||
symbol.clone(),
|
||||
symbol,
|
||||
(
|
||||
Located {
|
||||
value: ident.clone().into(),
|
||||
@ -1259,7 +1259,7 @@ fn closure_recursivity(symbol: Symbol, closures: &MutMap<Symbol, References>) ->
|
||||
|
||||
if let Some(references) = closures.get(&symbol) {
|
||||
for v in &references.calls {
|
||||
stack.push(v.clone());
|
||||
stack.push(*v);
|
||||
}
|
||||
|
||||
// while there are symbols left to visit
|
||||
@ -1275,7 +1275,7 @@ fn closure_recursivity(symbol: Symbol, closures: &MutMap<Symbol, References>) ->
|
||||
if let Some(nested_references) = closures.get(&nested_symbol) {
|
||||
// add its called to the stack
|
||||
for v in &nested_references.calls {
|
||||
stack.push(v.clone());
|
||||
stack.push(*v);
|
||||
}
|
||||
}
|
||||
visited.insert(nested_symbol);
|
||||
|
@ -450,7 +450,7 @@ pub fn canonicalize_expr<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
env.register_closure(symbol.clone(), output.references.clone());
|
||||
env.register_closure(symbol, output.references.clone());
|
||||
|
||||
(
|
||||
Closure(
|
||||
@ -818,7 +818,7 @@ where
|
||||
answer = answer.union(other_refs);
|
||||
}
|
||||
|
||||
answer.lookups.insert(local.clone());
|
||||
answer.lookups.insert(*local);
|
||||
}
|
||||
|
||||
for call in refs.calls.iter() {
|
||||
@ -828,7 +828,7 @@ where
|
||||
answer = answer.union(other_refs);
|
||||
}
|
||||
|
||||
answer.calls.insert(call.clone());
|
||||
answer.calls.insert(*call);
|
||||
}
|
||||
|
||||
answer
|
||||
@ -860,7 +860,7 @@ where
|
||||
answer = answer.union(other_refs);
|
||||
}
|
||||
|
||||
answer.lookups.insert(closed_over_local.clone());
|
||||
answer.lookups.insert(*closed_over_local);
|
||||
}
|
||||
|
||||
for call in references.calls.iter() {
|
||||
|
@ -57,7 +57,7 @@ pub fn symbols_from_pattern_help(pattern: &Pattern, symbols: &mut Vec<Symbol>) {
|
||||
|
||||
match pattern {
|
||||
Identifier(symbol) => {
|
||||
symbols.push(symbol.clone());
|
||||
symbols.push(*symbol);
|
||||
}
|
||||
|
||||
AppliedTag { arguments, .. } => {
|
||||
@ -67,7 +67,7 @@ pub fn symbols_from_pattern_help(pattern: &Pattern, symbols: &mut Vec<Symbol>) {
|
||||
}
|
||||
RecordDestructure { destructs, .. } => {
|
||||
for destruct in destructs {
|
||||
symbols.push(destruct.value.symbol.clone());
|
||||
symbols.push(destruct.value.symbol);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ fn headers_from_annotation_help(
|
||||
) -> bool {
|
||||
match pattern {
|
||||
Identifier(symbol) => {
|
||||
headers.insert(symbol.clone(), annotation.clone());
|
||||
headers.insert(*symbol, annotation.clone());
|
||||
true
|
||||
}
|
||||
Underscore
|
||||
@ -64,7 +64,7 @@ fn headers_from_annotation_help(
|
||||
// NOTE ignores the .guard field.
|
||||
if let Some(field_type) = fields.get(&destruct.value.label) {
|
||||
headers.insert(
|
||||
destruct.value.symbol.clone(),
|
||||
destruct.value.symbol,
|
||||
Located::at(annotation.region, field_type.clone()),
|
||||
);
|
||||
} else {
|
||||
@ -123,7 +123,7 @@ pub fn constrain_pattern(
|
||||
|
||||
Identifier(symbol) => {
|
||||
state.headers.insert(
|
||||
symbol.clone(),
|
||||
*symbol,
|
||||
Located {
|
||||
region,
|
||||
value: expected.get_type(),
|
||||
@ -197,7 +197,7 @@ pub fn constrain_pattern(
|
||||
if !state.headers.contains_key(&symbol) {
|
||||
state
|
||||
.headers
|
||||
.insert(symbol.clone(), Located::at(region, pat_type.clone()));
|
||||
.insert(*symbol, Located::at(region, pat_type.clone()));
|
||||
}
|
||||
|
||||
field_types.insert(label.clone(), pat_type.clone());
|
||||
|
@ -148,7 +148,7 @@ fn constrain_pattern(
|
||||
match &pattern.value {
|
||||
Identifier(symbol) => {
|
||||
state.headers.insert(
|
||||
symbol.clone(),
|
||||
*symbol,
|
||||
Located {
|
||||
region: pattern.region,
|
||||
value: expected.get_type(),
|
||||
@ -223,10 +223,9 @@ fn constrain_pattern(
|
||||
let expected = PExpected::NoExpectation(pat_type.clone());
|
||||
|
||||
if !state.headers.contains_key(&symbol) {
|
||||
state.headers.insert(
|
||||
symbol.clone(),
|
||||
Located::at(pattern.region, pat_type.clone()),
|
||||
);
|
||||
state
|
||||
.headers
|
||||
.insert(*symbol, Located::at(pattern.region, pat_type.clone()));
|
||||
}
|
||||
|
||||
field_types.insert(label.clone(), pat_type.clone());
|
||||
@ -1391,7 +1390,7 @@ fn constrain_var(
|
||||
Lookup(symbol_for_lookup, expected, region)
|
||||
}
|
||||
Some(Usage::Access(_, _, _)) | Some(Usage::Update(_, _, _)) => {
|
||||
applied_usage_constraint.insert(symbol_for_lookup.clone());
|
||||
applied_usage_constraint.insert(symbol_for_lookup);
|
||||
|
||||
let mut variables = Vec::new();
|
||||
let (free, rest, inner_type) =
|
||||
|
@ -280,7 +280,7 @@ fn pretty_runtime_error<'b>(
|
||||
if idents.is_empty() {
|
||||
alloc
|
||||
.reflow("The ")
|
||||
.append(alloc.ident(first.value.clone()))
|
||||
.append(alloc.ident(first.value))
|
||||
.append(alloc.reflow(
|
||||
" value is defined directly in terms of itself, causing an infinite loop.",
|
||||
))
|
||||
|
@ -333,7 +333,7 @@ fn solve(
|
||||
let var = type_to_var(subs, rank, pools, cached_aliases, &loc_type.value);
|
||||
|
||||
local_def_vars.insert(
|
||||
symbol.clone(),
|
||||
*symbol,
|
||||
Located {
|
||||
value: var,
|
||||
region: loc_type.region,
|
||||
@ -344,7 +344,7 @@ fn solve(
|
||||
let mut new_env = env.clone();
|
||||
for (symbol, loc_var) in local_def_vars.iter() {
|
||||
if !new_env.vars_by_symbol.contains_key(&symbol) {
|
||||
new_env.vars_by_symbol.insert(symbol.clone(), loc_var.value);
|
||||
new_env.vars_by_symbol.insert(*symbol, loc_var.value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ fn solve(
|
||||
type_to_var(subs, next_rank, next_pools, cached_aliases, &def_type);
|
||||
|
||||
local_def_vars.insert(
|
||||
symbol.clone(),
|
||||
*symbol,
|
||||
Located {
|
||||
value: var,
|
||||
region: loc_type.region,
|
||||
@ -469,7 +469,7 @@ fn solve(
|
||||
|
||||
for (symbol, loc_var) in local_def_vars.iter() {
|
||||
if !new_env.vars_by_symbol.contains_key(&symbol) {
|
||||
new_env.vars_by_symbol.insert(symbol.clone(), loc_var.value);
|
||||
new_env.vars_by_symbol.insert(*symbol, loc_var.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ impl Composable for VarUsage {
|
||||
}
|
||||
};
|
||||
|
||||
self.usage.insert(symbol.clone(), value);
|
||||
self.usage.insert(*symbol, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user