Skip to content

Speed up space-check rules with O(1) line/character lookups#633

Open
williamthome wants to merge 1 commit into
inaka:mainfrom
williamthome:perf/space-check-line-index
Open

Speed up space-check rules with O(1) line/character lookups#633
williamthome wants to merge 1 commit into
inaka:mainfrom
williamthome:perf/space-check-line-index

Conversation

@williamthome
Copy link
Copy Markdown
Contributor

@williamthome williamthome commented May 24, 2026

Description

operator_spaces, no_space, and no_space_after_pound fetched the source line and character with lists:nth/2 (O(n)) and re-decoded the line on every token, which is O(tokens × lines) per file. lines_in/1 now builds a per-line index once ({line, chars-tuple, length}), and character_at_location uses element/2. No behaviour change; lists:nth leaves the profile's hot path.

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.

1 participant