Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary Recursive Calls in user_begin_prompt Function #46

Open
abdelazizmohamad11 opened this issue Oct 31, 2024 · 0 comments
Open

Comments

@abdelazizmohamad11
Copy link

In the user_begin_prompt function, if the user provides an invalid input (neither "A" nor "B"), the function recursively calls itself to re-prompt the user. This can lead to excessive recursive calls, especially if the user continues entering invalid inputs, potentially causing a stack overflow. This recursive approach is not ideal for user input validation and can be replaced with a more efficient loop.

Suggested Solution: Replace the recursive calls with a while loop that continues until a valid input is received. This way, the function won’t create new frames on the stack for each invalid input, avoiding possible performance issues.

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

No branches or pull requests

1 participant