Skip to content

Conversation

@kddnewton
Copy link
Collaborator

Also, include the column in here. Hopefully we can do some additional optimizations later.

Also, include the column in here. Hopefully we can do some additional
optimizations later.
Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eregon
Copy link
Member

eregon commented Jan 27, 2026

Hopefully we can do some additional optimizations later.

What are you thinking to? That method looks already pretty much optimal, it's basically just an Array#[].

offsets[find_line(byte_offset) + 1] || source.bytesize
end

# Return the column number for the given byte offset.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Return the column in bytes for the given byte offset.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think we should avoid the term column number, at least I would interpret that as starting at 1 like an editor column. So I'd suggest to use column in bytes/characters/code units.
Happy to make a PR for that if you agree.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure yeah, happy to see that change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kddnewton
Copy link
Collaborator Author

Hopefully we can do some additional optimizations later.

What are you thinking to? That method looks already pretty much optimal, it's basically just an Array#[].

Not sure. Since we have both operands, we could potentially cache based on both. I'm not sure if it would be worth it, but I wanted to have both.

@kddnewton kddnewton merged commit 20dc949 into main Jan 27, 2026
65 of 66 checks passed
@kddnewton kddnewton deleted the byte-offset branch January 27, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants