From d8de45763037937b5c2dedbe5f7bb95a4e7bc7cd Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 30 Jan 2020 19:56:31 +0000 Subject: Avoid unnecessary allocations of `Value`s --- dhall/src/semantics/tck/env.rs | 2 +- dhall/src/semantics/tck/tyexpr.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'dhall/src/semantics/tck') diff --git a/dhall/src/semantics/tck/env.rs b/dhall/src/semantics/tck/env.rs index d4cc37d..812ca7a 100644 --- a/dhall/src/semantics/tck/env.rs +++ b/dhall/src/semantics/tck/env.rs @@ -118,7 +118,7 @@ impl TyEnv { } pub fn lookup(&self, var: &V) -> Option<(TyExprKind, Type)> { let var = self.names.unlabel_var(var)?; - let ty = self.items.lookup_val(&var).get_type().unwrap(); + let ty = self.items.lookup_ty(&var); Some((TyExprKind::Var(var), ty)) } } diff --git a/dhall/src/semantics/tck/tyexpr.rs b/dhall/src/semantics/tck/tyexpr.rs index 4b88048..1a048f9 100644 --- a/dhall/src/semantics/tck/tyexpr.rs +++ b/dhall/src/semantics/tck/tyexpr.rs @@ -1,5 +1,4 @@ use crate::error::{TypeError, TypeMessage}; -use crate::semantics::normalize_tyexpr_whnf; use crate::semantics::{rc, NameEnv, NzEnv, TyEnv, Value}; use crate::syntax::{ExprKind, Span, V}; use crate::Normalized; @@ -83,7 +82,9 @@ impl TyExpr { } /// Eval a closed TyExpr fully and recursively; pub fn rec_eval_closed_expr(&self) -> Value { - normalize_tyexpr_whnf(self, &NzEnv::new()) + let mut val = self.eval_closed_expr(); + val.normalize_mut(); + val } } -- cgit v1.2.3