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

Refactor FixCasingAfterTitles to use class fields. #8669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ivandrofly
Copy link
Member

Extracted the arrays _titles and _notChangeWords as readonly class fields to reduce redundancy and improve readability. Adjusted the associated logic to reference these fields instead of creating new arrays within the method.

Extracted the arrays `_titles` and `_notChangeWords` as readonly class fields to reduce redundancy and improve readability. Adjusted the associated logic to reference these fields instead of creating new arrays within the method.

Signed-off-by: Ivandro Jao <Ivandrofly@gmail.com>
@@ -159,24 +159,25 @@ private static string FixEnglishAloneILowerToUpper(string input)
return text;
}

private readonly string[] _titles = { "Mrs.", "Miss.", "Mr.", "Ms.", "Dr." };
private readonly string[] _notChangeWords = { "does", "has", "will", "is", "and", "for", "but", "or", "of" };
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved outside 'cause FixCasingAfterTitles is being callow inside a foreach-paragraph
which would alloc n*_titles + n*_notChangeWords

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