[OCR] - Minor optimizationss.

This commit is contained in:
Ivandro Ismael 2016-06-17 20:51:52 +00:00
parent 6b7131223f
commit 9d01dfb4d8

View File

@ -182,27 +182,21 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
{
if (s.Contains(from))
{
if (s.StartsWith(from))
if (s.StartsWith(from, StringComparison.Ordinal))
s = s.Remove(0, from.Length).Insert(0, _beginLineReplaceList[from]);
if (s.Contains(". " + from))
s = s.Replace(". " + from, ". " + _beginLineReplaceList[from]);
if (s.Contains("! " + from))
s = s.Replace("! " + from, "! " + _beginLineReplaceList[from]);
if (s.Contains("? " + from))
s = s.Replace("? " + from, "? " + _beginLineReplaceList[from]);
if (s.Contains("." + Environment.NewLine + from))
s = s.Replace(". " + Environment.NewLine + from, ". " + Environment.NewLine + _beginLineReplaceList[from]);
if (s.Contains("! " + Environment.NewLine + from))
s = s.Replace("! " + Environment.NewLine + from, "! " + Environment.NewLine + _beginLineReplaceList[from]);
if (s.Contains("? " + Environment.NewLine + from))
s = s.Replace("? " + Environment.NewLine + from, "? " + Environment.NewLine + _beginLineReplaceList[from]);
if (s.StartsWith('"') && !from.StartsWith('"') && s.StartsWith("\"" + from))
if (s.StartsWith("\"" + from, StringComparison.Ordinal) && !from.StartsWith('"'))
s = s.Replace("\"" + from, "\"" + _beginLineReplaceList[from]);
}
}
sb.AppendLine(s);
}
newText = pre + sb.ToString().TrimEnd('\r', '\n');
newText = pre + sb.ToString().TrimEnd(Utilities.NewLineChars);
string post = string.Empty;
if (newText.EndsWith("</i>", StringComparison.Ordinal))
@ -291,34 +285,16 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
{
word = word.Replace("fi", "fi");
word = word.Replace('ν', 'v'); // NOTE: first 'v' is a special unicode character!!!!
if (word.Contains(''))
word = word.Replace('', '\'');
if (word.Contains('`'))
word = word.Replace('`', '\'');
if (word.Contains(''))
word = word.Replace('', '\'');
if (word.Contains('—'))
word = word.Replace('—', '-');
while (word.Contains("--"))
word = word.Replace("--", "-");
if (word.Contains('|'))
word = word.Replace('|', 'l');
if (word.Contains("vx/"))
word = word.Replace("vx/", "w");
if (word.Contains('¤'))
{
if (Regex.IsMatch(word, "[A-ZÆØÅÄÖÉÈÀÙÂÊÎÔÛËÏa-zæøåäöéèàùâêîôûëï]¤"))
word = word.Replace('¤', 'o');
}
}
//always replace list
foreach (string letter in _partialWordReplaceListAlways.Keys)