Skip to content

Commit

Permalink
Move comment explaining use of line_info field into can::Env stru…
Browse files Browse the repository at this point in the history
…ct definition
  • Loading branch information
mulias committed Sep 5, 2024
1 parent 400b35f commit 55ad319
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/compiler/can/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LineInfo>,
}

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 55ad319

Please sign in to comment.