chore: avoid cloning name

This commit is contained in:
rvcas 2023-10-12 17:50:44 -04:00
parent 55f89a7ff4
commit e8bcbecf31
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
1 changed files with 8 additions and 9 deletions

View File

@ -782,21 +782,18 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
}; };
// Check to see if it's a Type that can have accessible fields // Check to see if it's a Type that can have accessible fields
let (accessors, name) = match collapse_links(record.tipo()).as_ref() { let accessors = match collapse_links(record.tipo()).as_ref() {
// A type in the current module which may have fields // A type in the current module which may have fields
Type::App { module, name, .. } if module == self.environment.current_module => self Type::App { module, name, .. } if module == self.environment.current_module => {
.environment self.environment.accessors.get(name)
.accessors }
.get(name)
.map(|t| (t, name.clone())),
// A type in another module which may have fields // A type in another module which may have fields
Type::App { module, name, .. } => self Type::App { module, name, .. } => self
.environment .environment
.importable_modules .importable_modules
.get(module) .get(module)
.and_then(|module| module.accessors.get(name)) .and_then(|module| module.accessors.get(name)),
.map(|accessors| (accessors, name.clone())),
_something_without_fields => return Err(unknown_field(vec![])), _something_without_fields => return Err(unknown_field(vec![])),
} }
@ -829,7 +826,9 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
false, false,
)?; )?;
self.environment.increment_usage(&name); if let Type::App { name, .. } = record.tipo().as_ref() {
self.environment.increment_usage(name);
};
Ok(TypedExpr::RecordAccess { Ok(TypedExpr::RecordAccess {
record, record,