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)
|
public void LoadUserDefaultFixes(string fixes)
|
||||||
{
|
{
|
||||||
var list = fixes.Split(';');
|
var hashSet = fixes.Split(';').ToHashSet();
|
||||||
EmptyLinesTicked = list.Contains(nameof(EmptyLinesTicked));
|
EmptyLinesTicked = hashSet.Contains(nameof(EmptyLinesTicked));
|
||||||
OverlappingDisplayTimeTicked = list.Contains(nameof(OverlappingDisplayTimeTicked));
|
OverlappingDisplayTimeTicked = hashSet.Contains(nameof(OverlappingDisplayTimeTicked));
|
||||||
TooShortDisplayTimeTicked = list.Contains(nameof(TooShortDisplayTimeTicked));
|
TooShortDisplayTimeTicked = hashSet.Contains(nameof(TooShortDisplayTimeTicked));
|
||||||
TooLongDisplayTimeTicked = list.Contains(nameof(TooLongDisplayTimeTicked));
|
TooLongDisplayTimeTicked = hashSet.Contains(nameof(TooLongDisplayTimeTicked));
|
||||||
TooShortGapTicked = list.Contains(nameof(TooShortGapTicked));
|
TooShortGapTicked = hashSet.Contains(nameof(TooShortGapTicked));
|
||||||
InvalidItalicTagsTicked = list.Contains(nameof(InvalidItalicTagsTicked));
|
InvalidItalicTagsTicked = hashSet.Contains(nameof(InvalidItalicTagsTicked));
|
||||||
BreakLongLinesTicked = list.Contains(nameof(BreakLongLinesTicked));
|
BreakLongLinesTicked = hashSet.Contains(nameof(BreakLongLinesTicked));
|
||||||
MergeShortLinesTicked = list.Contains(nameof(MergeShortLinesTicked));
|
MergeShortLinesTicked = hashSet.Contains(nameof(MergeShortLinesTicked));
|
||||||
MergeShortLinesAllTicked = list.Contains(nameof(MergeShortLinesAllTicked));
|
MergeShortLinesAllTicked = hashSet.Contains(nameof(MergeShortLinesAllTicked));
|
||||||
MergeShortLinesPixelWidthTicked = list.Contains(nameof(MergeShortLinesPixelWidthTicked));
|
MergeShortLinesPixelWidthTicked = hashSet.Contains(nameof(MergeShortLinesPixelWidthTicked));
|
||||||
UnneededSpacesTicked = list.Contains(nameof(UnneededSpacesTicked));
|
UnneededSpacesTicked = hashSet.Contains(nameof(UnneededSpacesTicked));
|
||||||
UnneededPeriodsTicked = list.Contains(nameof(UnneededPeriodsTicked));
|
UnneededPeriodsTicked = hashSet.Contains(nameof(UnneededPeriodsTicked));
|
||||||
FixCommasTicked = list.Contains(nameof(FixCommasTicked));
|
FixCommasTicked = hashSet.Contains(nameof(FixCommasTicked));
|
||||||
MissingSpacesTicked = list.Contains(nameof(MissingSpacesTicked));
|
MissingSpacesTicked = hashSet.Contains(nameof(MissingSpacesTicked));
|
||||||
AddMissingQuotesTicked = list.Contains(nameof(AddMissingQuotesTicked));
|
AddMissingQuotesTicked = hashSet.Contains(nameof(AddMissingQuotesTicked));
|
||||||
Fix3PlusLinesTicked = list.Contains(nameof(Fix3PlusLinesTicked));
|
Fix3PlusLinesTicked = hashSet.Contains(nameof(Fix3PlusLinesTicked));
|
||||||
FixHyphensTicked = list.Contains(nameof(FixHyphensTicked));
|
FixHyphensTicked = hashSet.Contains(nameof(FixHyphensTicked));
|
||||||
FixHyphensRemoveSingleLineTicked = list.Contains(nameof(FixHyphensRemoveSingleLineTicked));
|
FixHyphensRemoveSingleLineTicked = hashSet.Contains(nameof(FixHyphensRemoveSingleLineTicked));
|
||||||
UppercaseIInsideLowercaseWordTicked = list.Contains(nameof(UppercaseIInsideLowercaseWordTicked));
|
UppercaseIInsideLowercaseWordTicked = hashSet.Contains(nameof(UppercaseIInsideLowercaseWordTicked));
|
||||||
DoubleApostropheToQuoteTicked = list.Contains(nameof(DoubleApostropheToQuoteTicked));
|
DoubleApostropheToQuoteTicked = hashSet.Contains(nameof(DoubleApostropheToQuoteTicked));
|
||||||
AddPeriodAfterParagraphTicked = list.Contains(nameof(AddPeriodAfterParagraphTicked));
|
AddPeriodAfterParagraphTicked = hashSet.Contains(nameof(AddPeriodAfterParagraphTicked));
|
||||||
StartWithUppercaseLetterAfterParagraphTicked = list.Contains(nameof(StartWithUppercaseLetterAfterParagraphTicked));
|
StartWithUppercaseLetterAfterParagraphTicked = hashSet.Contains(nameof(StartWithUppercaseLetterAfterParagraphTicked));
|
||||||
StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = list.Contains(nameof(StartWithUppercaseLetterAfterPeriodInsideParagraphTicked));
|
StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = hashSet.Contains(nameof(StartWithUppercaseLetterAfterPeriodInsideParagraphTicked));
|
||||||
StartWithUppercaseLetterAfterColonTicked = list.Contains(nameof(StartWithUppercaseLetterAfterColonTicked));
|
StartWithUppercaseLetterAfterColonTicked = hashSet.Contains(nameof(StartWithUppercaseLetterAfterColonTicked));
|
||||||
AloneLowercaseIToUppercaseIEnglishTicked = list.Contains(nameof(AloneLowercaseIToUppercaseIEnglishTicked));
|
AloneLowercaseIToUppercaseIEnglishTicked = hashSet.Contains(nameof(AloneLowercaseIToUppercaseIEnglishTicked));
|
||||||
FixOcrErrorsViaReplaceListTicked = list.Contains(nameof(FixOcrErrorsViaReplaceListTicked));
|
FixOcrErrorsViaReplaceListTicked = hashSet.Contains(nameof(FixOcrErrorsViaReplaceListTicked));
|
||||||
RemoveSpaceBetweenNumberTicked = list.Contains(nameof(RemoveSpaceBetweenNumberTicked));
|
RemoveSpaceBetweenNumberTicked = hashSet.Contains(nameof(RemoveSpaceBetweenNumberTicked));
|
||||||
FixDialogsOnOneLineTicked = list.Contains(nameof(FixDialogsOnOneLineTicked));
|
FixDialogsOnOneLineTicked = hashSet.Contains(nameof(FixDialogsOnOneLineTicked));
|
||||||
RemoveDialogFirstLineInNonDialogs = list.Contains(nameof(RemoveDialogFirstLineInNonDialogs));
|
RemoveDialogFirstLineInNonDialogs = hashSet.Contains(nameof(RemoveDialogFirstLineInNonDialogs));
|
||||||
TurkishAnsiTicked = list.Contains(nameof(TurkishAnsiTicked));
|
TurkishAnsiTicked = hashSet.Contains(nameof(TurkishAnsiTicked));
|
||||||
DanishLetterITicked = list.Contains(nameof(DanishLetterITicked));
|
DanishLetterITicked = hashSet.Contains(nameof(DanishLetterITicked));
|
||||||
SpanishInvertedQuestionAndExclamationMarksTicked = list.Contains(nameof(SpanishInvertedQuestionAndExclamationMarksTicked));
|
SpanishInvertedQuestionAndExclamationMarksTicked = hashSet.Contains(nameof(SpanishInvertedQuestionAndExclamationMarksTicked));
|
||||||
FixDoubleDashTicked = list.Contains(nameof(FixDoubleDashTicked));
|
FixDoubleDashTicked = hashSet.Contains(nameof(FixDoubleDashTicked));
|
||||||
FixEllipsesStartTicked = list.Contains(nameof(FixEllipsesStartTicked));
|
FixEllipsesStartTicked = hashSet.Contains(nameof(FixEllipsesStartTicked));
|
||||||
FixMissingOpenBracketTicked = list.Contains(nameof(FixMissingOpenBracketTicked));
|
FixMissingOpenBracketTicked = hashSet.Contains(nameof(FixMissingOpenBracketTicked));
|
||||||
FixMusicNotationTicked = list.Contains(nameof(FixMusicNotationTicked));
|
FixMusicNotationTicked = hashSet.Contains(nameof(FixMusicNotationTicked));
|
||||||
FixContinuationStyleTicked = list.Contains(nameof(FixContinuationStyleTicked));
|
FixContinuationStyleTicked = hashSet.Contains(nameof(FixContinuationStyleTicked));
|
||||||
FixUnnecessaryLeadingDotsTicked = list.Contains(nameof(FixUnnecessaryLeadingDotsTicked));
|
FixUnnecessaryLeadingDotsTicked = hashSet.Contains(nameof(FixUnnecessaryLeadingDotsTicked));
|
||||||
NormalizeStringsTicked = list.Contains(nameof(NormalizeStringsTicked));
|
NormalizeStringsTicked = hashSet.Contains(nameof(NormalizeStringsTicked));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDefaultFixes()
|
public void SetDefaultFixes()
|
||||||
|
Loading…
Reference in New Issue
Block a user