[internal] - introduce more constant for var inside loop

This commit is contained in:
ivandrofly 2015-09-06 00:57:39 +01:00
parent 919ef34555
commit a98a00e13c
2 changed files with 5 additions and 4 deletions

View File

@ -215,7 +215,7 @@ namespace Nikse.SubtitleEdit.Core
if (makeUppercaseAfterBreak && StrippedText.Contains(new[] { '.', '!', '?', ':', ';', ')', ']', '}', '(', '[', '{' }))
{
const string breakAfterChars = @".!?:;)]}([{";
const string ExpectedChars = "\"`´'()<>!?.- \r\n";
var sb = new StringBuilder();
bool lastWasBreak = false;
for (int i = 0; i < StrippedText.Length; i++)
@ -223,7 +223,7 @@ namespace Nikse.SubtitleEdit.Core
var s = StrippedText[i];
if (lastWasBreak)
{
if (("\"`´'()<>!?.- " + Environment.NewLine).Contains(s))
if (ExpectedChars.Contains(s))
{
sb.Append(s);
}

View File

@ -87,18 +87,19 @@ namespace Nikse.SubtitleEdit.Forms
{
if (word != null && richTextBoxParagraph.Text.Contains(word))
{
const string ExpectedWordBoundaryChars = @" <>-""”“[]'`´¶()♪¿¡.…—!?,:;/\r\n";
for (int i = 0; i < richTextBoxParagraph.Text.Length; i++)
{
if (richTextBoxParagraph.Text.Substring(i).StartsWith(word))
{
bool startOk = i == 0;
if (!startOk)
startOk = (@" <>-""”“[]'`´¶()♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(richTextBoxParagraph.Text[i - 1]);
startOk = ExpectedWordBoundaryChars.Contains(richTextBoxParagraph.Text[i - 1]);
if (startOk)
{
bool endOk = (i + word.Length == richTextBoxParagraph.Text.Length);
if (!endOk)
endOk = (@" <>-""”“[]'`´¶()♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(richTextBoxParagraph.Text[i + word.Length]);
endOk = ExpectedWordBoundaryChars.Contains(richTextBoxParagraph.Text[i + word.Length]);
if (endOk)
{
richTextBoxParagraph.SelectionStart = i + 1;