Skip to content

refactor: replace recursion with loop in getStatementStart#261

Merged
joho merged 1 commit into
joho:mainfrom
Yanhu007:fix/getstatementstart-loop
May 19, 2026
Merged

refactor: replace recursion with loop in getStatementStart#261
joho merged 1 commit into
joho:mainfrom
Yanhu007:fix/getstatementstart-loop

Conversation

@Yanhu007
Copy link
Copy Markdown
Contributor

Ref #232

Converts the recursive getStatementStart function to an iterative loop. The behavior is identical, but the iterative version:

  • Prevents potential stack overflow on files with many consecutive comment lines
  • Is slightly more idiomatic Go
  • Is marginally more efficient (no recursive call overhead)

All existing tests pass.

Convert the recursive getStatementStart function to an iterative
loop. This prevents potential stack overflow on files with a very
large number of consecutive comment lines.

Ref joho#232
joho added a commit that referenced this pull request May 19, 2026
@joho joho merged commit 3ec7e17 into joho:main May 19, 2026
2 checks passed
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.

2 participants