Skip to content

refactor: replace recursion with loop in getStatementStart#261

Open
Yanhu007 wants to merge 1 commit intojoho:mainfrom
Yanhu007:fix/getstatementstart-loop
Open

refactor: replace recursion with loop in getStatementStart#261
Yanhu007 wants to merge 1 commit intojoho:mainfrom
Yanhu007:fix/getstatementstart-loop

Conversation

@Yanhu007
Copy link
Copy Markdown

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
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