mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Optimize user fixes list by using HashSet
Refactored `LoadUserDefaultFixes` method to utilize `HashSet` for checking fix names, improving lookup efficiency. This change enhances performance when loading user-specific fixes by reducing the complexity of contains operations. Signed-off-by: Ivandro Jao <Ivandrofly@gmail.com>
This commit is contained in:
parent
4af0572d87
commit
1d1d1bb4ce
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user