mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
don't clone Layout
This commit is contained in:
parent
fa013e7d01
commit
55cb780249
18 changed files with 250 additions and 360 deletions
|
@ -258,7 +258,7 @@ impl<'a> ClosureLayout<'a> {
|
|||
// define the function pointer
|
||||
let function_ptr_layout = {
|
||||
let mut temp = Vec::from_iter_in(argument_layouts.iter().cloned(), arena);
|
||||
temp.push(closure_data_layout.clone());
|
||||
temp.push(*closure_data_layout);
|
||||
Layout::FunctionPointer(temp.into_bump_slice(), ret_layout)
|
||||
};
|
||||
|
||||
|
@ -278,8 +278,8 @@ impl<'a> ClosureLayout<'a> {
|
|||
pub fn as_named_layout(&self, symbol: Symbol) -> Layout<'a> {
|
||||
let layouts = if self.captured.is_empty() {
|
||||
match self.layout {
|
||||
Layout::Struct(fields) if fields.len() == 1 => fields[0].clone(),
|
||||
other => other.clone(),
|
||||
Layout::Struct(fields) if fields.len() == 1 => fields[0],
|
||||
other => *other,
|
||||
}
|
||||
} else if let Some((_, tag_args)) = self
|
||||
.captured
|
||||
|
@ -287,7 +287,7 @@ impl<'a> ClosureLayout<'a> {
|
|||
.find(|(tn, _)| *tn == TagName::Closure(symbol))
|
||||
{
|
||||
if tag_args.len() == 1 {
|
||||
tag_args[0].clone()
|
||||
tag_args[0]
|
||||
} else {
|
||||
Layout::Struct(tag_args)
|
||||
}
|
||||
|
@ -303,13 +303,13 @@ impl<'a> ClosureLayout<'a> {
|
|||
|
||||
pub fn as_block_of_memory_layout(&self) -> Layout<'a> {
|
||||
match self.layout {
|
||||
Layout::Struct(fields) if fields.len() == 1 => fields[0].clone(),
|
||||
other => other.clone(),
|
||||
Layout::Struct(fields) if fields.len() == 1 => fields[0],
|
||||
other => *other,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn internal_layout(&self) -> Layout<'a> {
|
||||
self.layout.clone()
|
||||
*self.layout
|
||||
}
|
||||
|
||||
pub fn build_closure_data(
|
||||
|
@ -825,7 +825,7 @@ impl<'a> LayoutCache<'a> {
|
|||
// of a problem
|
||||
if false {
|
||||
let cached_layout = match &result {
|
||||
Ok(layout) => Cached(layout.clone()),
|
||||
Ok(layout) => Cached(*layout),
|
||||
Err(problem) => Problem(problem.clone()),
|
||||
};
|
||||
|
||||
|
@ -2057,7 +2057,7 @@ impl<'a> LayoutIds<'a> {
|
|||
// If we had to default to next_id, it must not have been found;
|
||||
// store the ID we're going to return and increment next_id.
|
||||
if answer == ids.next_id {
|
||||
ids.by_id.insert(layout.clone(), ids.next_id);
|
||||
ids.by_id.insert(*layout, ids.next_id);
|
||||
|
||||
ids.next_id += 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue