Improve efficiency of NoBreakAfterItem.IsMatch()

Refact commit dce7c5a6d6.
This commit is contained in:
Waldi Ravens 2019-11-28 13:53:51 +01:00
parent d4f1e4f28f
commit 5fbf4a9ad4

View File

@ -32,7 +32,13 @@ namespace Nikse.SubtitleEdit.Core
return Regex.IsMatch(line); return Regex.IsMatch(line);
} }
return line.EndsWith($" {Text}", StringComparison.Ordinal) || line.Equals(Text, StringComparison.Ordinal); if (line.EndsWith(Text, StringComparison.Ordinal))
{
var indexBeforeText = line.Length - Text.Length - 1;
return indexBeforeText < 0 || line[indexBeforeText] == ' ';
}
return false;
} }
public override string ToString() public override string ToString()