Skip to content

Question: A good idea to call line_col at every node? #228

@arjunguha

Description

@arjunguha

This is really a question, and not an issue:

I am building an AST and want to store a source location at every node. The simplest approach is to store the result of
line_col. However, skimming the code suggests that this may not be a good idea. I believe each call to line_col may scan over every prior newline in the file:

fn line_col(&self, span: Span) -> ((usize, usize), (usize, usize)) {

Is that accurate? If so, I suppose the smart approach is to store a Span, and only invoke line_col when I need to print a location.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions