diff options
author | Nadrieril | 2020-04-06 18:47:17 +0100 |
---|---|---|
committer | Nadrieril | 2020-04-06 18:47:17 +0100 |
commit | 28c36acc8af1e3ece9512c98aa9fd70fedf1b252 (patch) | |
tree | f13b512a17e1c6593cfe41e1cfd69e460ba0f51d /dhall/src/semantics/nze/nir.rs | |
parent | 7efdbd11db0f54f065d4dc41f0cab4b158d4515c (diff) |
Avoid a few allocations
Diffstat (limited to 'dhall/src/semantics/nze/nir.rs')
-rw-r--r-- | dhall/src/semantics/nze/nir.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/dhall/src/semantics/nze/nir.rs b/dhall/src/semantics/nze/nir.rs index 2b7a819..0dff105 100644 --- a/dhall/src/semantics/nze/nir.rs +++ b/dhall/src/semantics/nze/nir.rs @@ -111,8 +111,7 @@ impl Nir { NirInternal::from_whnf(v).into_nir() } pub fn from_const(c: Const) -> Self { - let v = NirKind::Const(c); - NirInternal::from_whnf(v).into_nir() + Self::from_kind(NirKind::Const(c)) } pub fn from_builtin(b: Builtin) -> Self { Self::from_builtin_env(b, &NzEnv::new()) @@ -148,7 +147,10 @@ impl Nir { } pub fn app(&self, v: Nir) -> Nir { - Nir::from_kind(apply_any(self.clone(), v)) + Nir::from_kind(self.app_to_kind(v)) + } + pub fn app_to_kind(&self, v: Nir) -> NirKind { + apply_any(self, v) } pub fn to_hir(&self, venv: VarEnv) -> Hir { |