From 497633c1bed170e61e39588165381676ef9b8c9a Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Mon, 17 Apr 2017 11:15:57 +0200 Subject: [PATCH] Minor refact --- libse/UknownFormatImporter.cs | 2 +- src/Forms/Main.cs | 11 ++--------- src/Forms/SpellCheck.cs | 10 +++++----- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/libse/UknownFormatImporter.cs b/libse/UknownFormatImporter.cs index f2a5833d2..717b66584 100644 --- a/libse/UknownFormatImporter.cs +++ b/libse/UknownFormatImporter.cs @@ -431,7 +431,7 @@ namespace Nikse.SubtitleEdit.Core foreach (Paragraph paragraph in subtitle.Paragraphs) { string text = paragraph.Text.Trim(); - if (text.StartsWith(prefix)) + if (text.StartsWith(prefix, StringComparison.Ordinal)) paragraph.Text = text.Remove(0, prefix.Length); } } diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 459fe22b4..28564d878 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -3754,14 +3754,7 @@ namespace Nikse.SubtitleEdit.Forms // Set default RTL or LTR if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) { - if (Configuration.Settings.General.RightToLeftMode) - { - textBoxListViewTextAlternate.RightToLeft = RightToLeft.Yes; - } - else - { - textBoxListViewTextAlternate.RightToLeft = RightToLeft.No; - } + textBoxListViewTextAlternate.RightToLeft = Configuration.Settings.General.RightToLeftMode ? RightToLeft.Yes : RightToLeft.No; } if (Configuration.Settings.General.RightToLeftMode) { @@ -12390,7 +12383,7 @@ namespace Nikse.SubtitleEdit.Forms { if (line.TrimStart().StartsWith('-') || line.TrimStart().StartsWith("-", StringComparison.Ordinal) || line.TrimStart().StartsWith(" -", StringComparison.Ordinal)) sb.AppendLine(line); - else if (line.TrimStart().StartsWith("") && line.Trim().Length > 3) + else if (line.TrimStart().StartsWith("", StringComparison.Ordinal) && line.Trim().Length > 3) sb.AppendLine("- " + line.Substring(3).TrimStart()); else sb.AppendLine("- " + line); diff --git a/src/Forms/SpellCheck.cs b/src/Forms/SpellCheck.cs index d48808300..250d8cdb0 100644 --- a/src/Forms/SpellCheck.cs +++ b/src/Forms/SpellCheck.cs @@ -158,7 +158,7 @@ namespace Nikse.SubtitleEdit.Forms for (int i = 0; i < 10; i++) { int idx = word.Index - i; - if (idx >= 0 && idx < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text)) + if (idx >= 0 && idx < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text, StringComparison.Ordinal)) { richTextBoxParagraph.SelectionStart = idx; richTextBoxParagraph.SelectionLength = word.Text.Length; @@ -166,7 +166,7 @@ namespace Nikse.SubtitleEdit.Forms break; } idx = word.Index + i; - if (idx >= 0 && idx < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text)) + if (idx >= 0 && idx < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text, StringComparison.Ordinal)) { richTextBoxParagraph.SelectionStart = idx; richTextBoxParagraph.SelectionLength = word.Text.Length; @@ -593,7 +593,7 @@ namespace Nikse.SubtitleEdit.Forms var suggestions = new List(); - if ((_currentWord == "Lt's" || _currentWord == "Lt'S") && _languageName.StartsWith("en_")) + if ((_currentWord == "Lt's" || _currentWord == "Lt'S") && _languageName.StartsWith("en_", StringComparison.Ordinal)) { suggestions.Add("It's"); } @@ -610,7 +610,7 @@ namespace Nikse.SubtitleEdit.Forms { for (int i = 0; i < suggestions.Count; i++) { - if (suggestions[i].StartsWith("L'") || suggestions[i].StartsWith("L’")) + if (suggestions[i].StartsWith("L'", StringComparison.Ordinal) || suggestions[i].StartsWith("L’", StringComparison.Ordinal)) suggestions[i] = @"l" + suggestions[i].Substring(1); } } @@ -658,7 +658,7 @@ namespace Nikse.SubtitleEdit.Forms return; } } - if (_prefix != null && _prefix == "''" && _currentWord.EndsWith("''")) + if (_prefix != null && _prefix == "''" && _currentWord.EndsWith("''", StringComparison.Ordinal)) { _prefix = string.Empty; _currentSpellCheckWord.Index += 2;