From 6a763de51fc01067e87a5abc1261e20e32c13483 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 20 Apr 2019 22:49:46 +0200 Subject: shift by mutable ref to avoid reallocations --- dhall/src/normalize.rs | 151 +++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 80 deletions(-) (limited to 'dhall') diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index f6ec09c..ec25010 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -29,6 +29,16 @@ impl<'a> Typed<'a> { } } +fn shift0_mut(delta: isize, label: &Label, in_expr: &mut SubExpr) { + let new_expr = shift0(delta, label, &in_expr); + std::mem::replace(in_expr, new_expr); +} + +fn shift_mut(delta: isize, var: &V