From 89e58e7a22b703a6d827367ce433678bfc3d57b9 Mon Sep 17 00:00:00 2001 From: Waldi Ravens Date: Sun, 14 Jun 2015 15:16:22 +0200 Subject: [PATCH] Use Contains(char[]) instead of multiple Contains(char) (Forms/FixCommonErrors) --- src/Forms/FixCommonErrors.cs | 8 ++++---- src/Logic/Forms/FixCommonErrorsHelper.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Forms/FixCommonErrors.cs b/src/Forms/FixCommonErrors.cs index 054c49b10..3d3443406 100644 --- a/src/Forms/FixCommonErrors.cs +++ b/src/Forms/FixCommonErrors.cs @@ -1463,7 +1463,7 @@ namespace Nikse.SubtitleEdit.Forms } //fix missing spaces before/after music quotes - #He's so happy# -> #He's so happy# - if ((p.Text.Contains('#') || p.Text.Contains('♪') || p.Text.Contains('♫')) && p.Text.Length > 5) + if (p.Text.Length > 5 && p.Text.Contains(new[] { '#', '♪', '♫' })) { string newText = p.Text; if (@"#♪♫".Contains(newText[0]) && !@" <".Contains(newText[1]) && !newText.Substring(1).StartsWith(Environment.NewLine) && @@ -1945,7 +1945,7 @@ namespace Nikse.SubtitleEdit.Forms nextText = HtmlUtil.RemoveHtmlTags(next.Text).TrimStart('-', '"', '„').TrimStart(); string tempNoHtml = HtmlUtil.RemoveHtmlTags(p.Text).TrimEnd(); - if (IsOneLineUrl(p.Text) || p.Text.Contains('♪') || p.Text.Contains('♫') || p.Text.EndsWith('\'')) + if (IsOneLineUrl(p.Text) || p.Text.Contains(new[] { '♪', '♫' }) || p.Text.EndsWith('\'')) { // ignore urls } @@ -2495,7 +2495,7 @@ namespace Nikse.SubtitleEdit.Forms } } - if (oldText.Contains(':') || oldText.Contains(';')) + if (oldText.Contains(new[] { ':', ';' })) { bool lastWasColon = false; for (int j = 0; j < p.Text.Length; j++) @@ -5057,4 +5057,4 @@ namespace Nikse.SubtitleEdit.Forms } } -} \ No newline at end of file +} diff --git a/src/Logic/Forms/FixCommonErrorsHelper.cs b/src/Logic/Forms/FixCommonErrorsHelper.cs index edc99977b..bae947490 100644 --- a/src/Logic/Forms/FixCommonErrorsHelper.cs +++ b/src/Logic/Forms/FixCommonErrorsHelper.cs @@ -451,7 +451,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms { s = s.TrimEnd().TrimEnd('.', '?', '!', ':', ';'); s = s.TrimStart('-'); - if (s.IndexOfAny(new[] { '.', '?', '!', ':', ';', '-', '♪', '♫' }) < 0 && + if (!s.Contains(new[] { '.', '?', '!', ':', ';', '-', '♪', '♫' }) && !(s.StartsWith('[') && s.Contains("]" + Environment.NewLine, StringComparison.Ordinal)) && !(s.StartsWith('(') && s.Contains(")" + Environment.NewLine, StringComparison.Ordinal)) && s != s.ToUpper()) @@ -463,4 +463,4 @@ namespace Nikse.SubtitleEdit.Logic.Forms } } -} \ No newline at end of file +}