Don't clone fillet data
Fillet data was being cloned just to check if there were any duplicate elements in a vector. That's not necessary, we can just check the len before and after deduplicating.
This commit is contained in:
@ -121,24 +121,24 @@ pub async fn fillet(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
|||||||
name = "fillet",
|
name = "fillet",
|
||||||
}]
|
}]
|
||||||
async fn inner_fillet(
|
async fn inner_fillet(
|
||||||
data: FilletData,
|
mut data: FilletData,
|
||||||
solid: Box<Solid>,
|
mut solid: Box<Solid>,
|
||||||
tag: Option<TagDeclarator>,
|
tag: Option<TagDeclarator>,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
args: Args,
|
args: Args,
|
||||||
) -> Result<Box<Solid>, KclError> {
|
) -> Result<Box<Solid>, KclError> {
|
||||||
// Check if tags contains any duplicate values.
|
// Check if tags contains any duplicate values.
|
||||||
let mut tags = data.tags.clone();
|
let num_tags = data.tags.len();
|
||||||
tags.sort();
|
data.tags.sort();
|
||||||
tags.dedup();
|
data.tags.dedup();
|
||||||
if tags.len() != data.tags.len() {
|
if num_tags != data.tags.len() {
|
||||||
return Err(KclError::Type(KclErrorDetails {
|
return Err(KclError::Type(KclErrorDetails {
|
||||||
message: "Duplicate tags are not allowed.".to_string(),
|
message: "Duplicate tags are not allowed.".to_string(),
|
||||||
source_ranges: vec![args.source_range],
|
source_ranges: vec![args.source_range],
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
let data = data; // remove mutability
|
||||||
|
|
||||||
let mut solid = solid.clone();
|
|
||||||
for edge_tag in data.tags {
|
for edge_tag in data.tags {
|
||||||
let edge_id = edge_tag.get_engine_id(exec_state, &args)?;
|
let edge_id = edge_tag.get_engine_id(exec_state, &args)?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user