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

Fix Empty WordDelimiters Handling in IsWordDelim and DelimiterClass #18376

Conversation

xbqofxa4cnmeopfsyiiam36qwgf3svheb3n8q1o
Copy link

Summary of the Pull Request

This pull request addresses the handling of empty WordDelimiters lists to ensure stable and predictable behavior across all relevant functions.

References and Relevant Issues

N/A

Detailed Description of the Pull Request / Additional Comments

  • IsWordDelim function updates:

    • Added a condition to check if WordDelimiters is empty before proceeding with the standard logic.
    • Ensures that the function remains compatible with existing behavior while handling edge cases more effectively.
  • DelimiterClass function updates:

    • Similar logic applied to avoid unnecessary operations if WordDelimiters is empty.
    • Maintains compatibility and prevents errors related to uninitialized or empty delimiter lists.

These updates improve the stability of the codebase and align with best practices for handling potentially undefined states.

Validation Steps Performed

  • Verified the behavior of IsWordDelim and DelimiterClass with both empty and non-empty WordDelimiters.
  • Conducted manual testing to ensure there are no regressions or unexpected changes in functionality.

PR Checklist

  • Closes N/A
  • Tests added/passed: Verified functionality with both empty and non-empty WordDelimiters.
  • Documentation updated: No documentation updates required for this change.
  • Schema updated (if necessary): Not applicable.

Added a check to verify that the WordDelimiters list is not empty before accessing it. This prevents potential errors that may occur if the list is uninitialized or empty, ensuring more stable behavior in the program.
- Add a check for empty WordDelimiters list before searching for delimiters.
- This improves efficiency by preventing unnecessary searches when the list is empty.
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

std::ranges::find does the same check internally!

Thanks, though. :)

@DHowett DHowett closed this Jan 6, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jan 6, 2025
@xbqofxa4cnmeopfsyiiam36qwgf3svheb3n8q1o

std::ranges::find does the same check internally!

Thanks, though. :)

Thank you so much for your feedback!

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants