Merge pull request #9008 from ivandrofly/feature/fce-settings

Optimize user fixes list by using HashSet
This commit is contained in:
Nikolaj Olsson 2024-11-20 19:07:01 +01:00 committed by GitHub
commit c1754a0343
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -259,46 +259,46 @@ namespace Nikse.SubtitleEdit.Core.Settings
public void LoadUserDefaultFixes(string fixes)
{
var list = fixes.Split(';');
EmptyLinesTicked = list.Contains(nameof(EmptyLinesTicked));
OverlappingDisplayTimeTicked = list.Contains(nameof(OverlappingDisplayTimeTicked));
TooShortDisplayTimeTicked = list.Contains(nameof(TooShortDisplayTimeTicked));
TooLongDisplayTimeTicked = list.Contains(nameof(TooLongDisplayTimeTicked));
TooShortGapTicked = list.Contains(nameof(TooShortGapTicked));
InvalidItalicTagsTicked = list.Contains(nameof(InvalidItalicTagsTicked));
BreakLongLinesTicked = list.Contains(nameof(BreakLongLinesTicked));
MergeShortLinesTicked = list.Contains(nameof(MergeShortLinesTicked));
MergeShortLinesAllTicked = list.Contains(nameof(MergeShortLinesAllTicked));
MergeShortLinesPixelWidthTicked = list.Contains(nameof(MergeShortLinesPixelWidthTicked));
UnneededSpacesTicked = list.Contains(nameof(UnneededSpacesTicked));
UnneededPeriodsTicked = list.Contains(nameof(UnneededPeriodsTicked));
FixCommasTicked = list.Contains(nameof(FixCommasTicked));
MissingSpacesTicked = list.Contains(nameof(MissingSpacesTicked));
AddMissingQuotesTicked = list.Contains(nameof(AddMissingQuotesTicked));
Fix3PlusLinesTicked = list.Contains(nameof(Fix3PlusLinesTicked));
FixHyphensTicked = list.Contains(nameof(FixHyphensTicked));
FixHyphensRemoveSingleLineTicked = list.Contains(nameof(FixHyphensRemoveSingleLineTicked));
UppercaseIInsideLowercaseWordTicked = list.Contains(nameof(UppercaseIInsideLowercaseWordTicked));
DoubleApostropheToQuoteTicked = list.Contains(nameof(DoubleApostropheToQuoteTicked));
AddPeriodAfterParagraphTicked = list.Contains(nameof(AddPeriodAfterParagraphTicked));
StartWithUppercaseLetterAfterParagraphTicked = list.Contains(nameof(StartWithUppercaseLetterAfterParagraphTicked));
StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = list.Contains(nameof(StartWithUppercaseLetterAfterPeriodInsideParagraphTicked));
StartWithUppercaseLetterAfterColonTicked = list.Contains(nameof(StartWithUppercaseLetterAfterColonTicked));
AloneLowercaseIToUppercaseIEnglishTicked = list.Contains(nameof(AloneLowercaseIToUppercaseIEnglishTicked));
FixOcrErrorsViaReplaceListTicked = list.Contains(nameof(FixOcrErrorsViaReplaceListTicked));
RemoveSpaceBetweenNumberTicked = list.Contains(nameof(RemoveSpaceBetweenNumberTicked));
FixDialogsOnOneLineTicked = list.Contains(nameof(FixDialogsOnOneLineTicked));
RemoveDialogFirstLineInNonDialogs = list.Contains(nameof(RemoveDialogFirstLineInNonDialogs));
TurkishAnsiTicked = list.Contains(nameof(TurkishAnsiTicked));
DanishLetterITicked = list.Contains(nameof(DanishLetterITicked));
SpanishInvertedQuestionAndExclamationMarksTicked = list.Contains(nameof(SpanishInvertedQuestionAndExclamationMarksTicked));
FixDoubleDashTicked = list.Contains(nameof(FixDoubleDashTicked));
FixEllipsesStartTicked = list.Contains(nameof(FixEllipsesStartTicked));
FixMissingOpenBracketTicked = list.Contains(nameof(FixMissingOpenBracketTicked));
FixMusicNotationTicked = list.Contains(nameof(FixMusicNotationTicked));
FixContinuationStyleTicked = list.Contains(nameof(FixContinuationStyleTicked));
FixUnnecessaryLeadingDotsTicked = list.Contains(nameof(FixUnnecessaryLeadingDotsTicked));
NormalizeStringsTicked = list.Contains(nameof(NormalizeStringsTicked));
var hashSet = fixes.Split(';').ToHashSet();
EmptyLinesTicked = hashSet.Contains(nameof(EmptyLinesTicked));
OverlappingDisplayTimeTicked = hashSet.Contains(nameof(OverlappingDisplayTimeTicked));
TooShortDisplayTimeTicked = hashSet.Contains(nameof(TooShortDisplayTimeTicked));
TooLongDisplayTimeTicked = hashSet.Contains(nameof(TooLongDisplayTimeTicked));
TooShortGapTicked = hashSet.Contains(nameof(TooShortGapTicked));
InvalidItalicTagsTicked = hashSet.Contains(nameof(InvalidItalicTagsTicked));
BreakLongLinesTicked = hashSet.Contains(nameof(BreakLongLinesTicked));
MergeShortLinesTicked = hashSet.Contains(nameof(MergeShortLinesTicked));
MergeShortLinesAllTicked = hashSet.Contains(nameof(MergeShortLinesAllTicked));
MergeShortLinesPixelWidthTicked = hashSet.Contains(nameof(MergeShortLinesPixelWidthTicked));
UnneededSpacesTicked = hashSet.Contains(nameof(UnneededSpacesTicked));
UnneededPeriodsTicked = hashSet.Contains(nameof(UnneededPeriodsTicked));
FixCommasTicked = hashSet.Contains(nameof(FixCommasTicked));
MissingSpacesTicked = hashSet.Contains(nameof(MissingSpacesTicked));
AddMissingQuotesTicked = hashSet.Contains(nameof(AddMissingQuotesTicked));
Fix3PlusLinesTicked = hashSet.Contains(nameof(Fix3PlusLinesTicked));
FixHyphensTicked = hashSet.Contains(nameof(FixHyphensTicked));
FixHyphensRemoveSingleLineTicked = hashSet.Contains(nameof(FixHyphensRemoveSingleLineTicked));
UppercaseIInsideLowercaseWordTicked = hashSet.Contains(nameof(UppercaseIInsideLowercaseWordTicked));
DoubleApostropheToQuoteTicked = hashSet.Contains(nameof(DoubleApostropheToQuoteTicked));
AddPeriodAfterParagraphTicked = hashSet.Contains(nameof(AddPeriodAfterParagraphTicked));
StartWithUppercaseLetterAfterParagraphTicked = hashSet.Contains(nameof(StartWithUppercaseLetterAfterParagraphTicked));
StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = hashSet.Contains(nameof(StartWithUppercaseLetterAfterPeriodInsideParagraphTicked));
StartWithUppercaseLetterAfterColonTicked = hashSet.Contains(nameof(StartWithUppercaseLetterAfterColonTicked));
AloneLowercaseIToUppercaseIEnglishTicked = hashSet.Contains(nameof(AloneLowercaseIToUppercaseIEnglishTicked));
FixOcrErrorsViaReplaceListTicked = hashSet.Contains(nameof(FixOcrErrorsViaReplaceListTicked));
RemoveSpaceBetweenNumberTicked = hashSet.Contains(nameof(RemoveSpaceBetweenNumberTicked));
FixDialogsOnOneLineTicked = hashSet.Contains(nameof(FixDialogsOnOneLineTicked));
RemoveDialogFirstLineInNonDialogs = hashSet.Contains(nameof(RemoveDialogFirstLineInNonDialogs));
TurkishAnsiTicked = hashSet.Contains(nameof(TurkishAnsiTicked));
DanishLetterITicked = hashSet.Contains(nameof(DanishLetterITicked));
SpanishInvertedQuestionAndExclamationMarksTicked = hashSet.Contains(nameof(SpanishInvertedQuestionAndExclamationMarksTicked));
FixDoubleDashTicked = hashSet.Contains(nameof(FixDoubleDashTicked));
FixEllipsesStartTicked = hashSet.Contains(nameof(FixEllipsesStartTicked));
FixMissingOpenBracketTicked = hashSet.Contains(nameof(FixMissingOpenBracketTicked));
FixMusicNotationTicked = hashSet.Contains(nameof(FixMusicNotationTicked));
FixContinuationStyleTicked = hashSet.Contains(nameof(FixContinuationStyleTicked));
FixUnnecessaryLeadingDotsTicked = hashSet.Contains(nameof(FixUnnecessaryLeadingDotsTicked));
NormalizeStringsTicked = hashSet.Contains(nameof(NormalizeStringsTicked));
}
public void SetDefaultFixes()