Skip to content

Commit

Permalink
Don't clone Scope::get
Browse files Browse the repository at this point in the history
  • Loading branch information
emk committed Oct 26, 2023
1 parent 7dbfef9 commit 527c26a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ mod tests {
}

fn lookup(scope: &ScopeHandle, name: &str) -> Option<Type<TypeVar>> {
scope.get(&CaseInsensitiveIdent::new(name, Span::Unknown))
scope
.get(&CaseInsensitiveIdent::new(name, Span::Unknown))
.cloned()
}

macro_rules! assert_defines {
Expand Down
4 changes: 2 additions & 2 deletions src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ impl Scope {
}

/// Get a value from the scope.
pub fn get(&self, name: &CaseInsensitiveIdent) -> Option<ScopeValue> {
pub fn get<'scope>(&'scope self, name: &CaseInsensitiveIdent) -> Option<&'scope ScopeValue> {
match self.names.get(name) {
Some(ScopeEntry::Defined(value)) => Some(value.to_owned()),
Some(ScopeEntry::Defined(value)) => Some(value),
Some(ScopeEntry::Hidden) => None,
None => {
if let Some(parent) = self.parent.as_ref() {
Expand Down

0 comments on commit 527c26a

Please sign in to comment.