From 85acb6826966a04fe1616f336c26947f561cc570 Mon Sep 17 00:00:00 2001 From: Lucas Clemente Vella Date: Tue, 26 Sep 2023 21:34:49 +0100 Subject: [PATCH] Skip diff computation if not needed. --- ast/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ast/src/lib.rs b/ast/src/lib.rs index ad614d7226..ebe612a4e6 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -1,4 +1,5 @@ use itertools::Itertools; +use log::log_enabled; use number::FieldElement; use parsed::{BinaryOperator, UnaryOperator}; use std::fmt::{Display, Result, Write}; @@ -25,8 +26,8 @@ impl DiffMonitor { std::mem::swap(&mut self.previous, &mut self.current); self.current = Some(s.to_string()); - if let Some(current) = &self.current { - if let Some(previous) = &self.previous { + if log_enabled!(log::Level::Trace) { + if let (Some(current), Some(previous)) = (&self.current, &self.previous) { for diff in diff::lines(previous, current) { match diff { diff::Result::Left(l) => log::trace!("-{}", l),