From 55ad319b3005fd9cf96d2ad9d5d1ee2ce2d8ae3a Mon Sep 17 00:00:00 2001 From: Elias Mulhall Date: Thu, 5 Sep 2024 19:18:23 -0400 Subject: [PATCH] Move comment explaining use of `line_info` field into `can::Env` struct definition --- crates/compiler/can/src/env.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/compiler/can/src/env.rs b/crates/compiler/can/src/env.rs index c90a6456be..f2fa78c895 100644 --- a/crates/compiler/can/src/env.rs +++ b/crates/compiler/can/src/env.rs @@ -47,6 +47,9 @@ pub struct Env<'a> { pub src: &'a str, + /// Lazily calculated line info. This data is only needed if the code contains calls to `dbg`, + /// otherwise we can leave it as `None` and never pay the cast of scanning the source an extra + /// time. line_info: &'a mut Option, } @@ -227,9 +230,6 @@ impl<'a> Env<'a> { self.problems.push(problem) } - /// Lazily calculate line_info only if required. This way it there are no - /// `dbg` statements, we never pay the cast of scanning the source an extra - /// time. pub fn line_info(&mut self) -> &LineInfo { if self.line_info.is_none() { *self.line_info = Some(LineInfo::new(self.src));