mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 03:33:18 +01:00
Minor performance improvements
This commit is contained in:
parent
1244287821
commit
52fa865572
@ -151,9 +151,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string textToLower = text.ToLower();
|
||||
foreach (string name in namesEtcList)
|
||||
{
|
||||
if (textToLower.Contains(name.ToLower())) // Optimization - Contains is much faster than IndexOf
|
||||
{
|
||||
int startIndex = textToLower.IndexOf(name.ToLower(), StringComparison.Ordinal);
|
||||
int startIndex = textToLower.IndexOf(name.ToLower(), StringComparison.Ordinal);
|
||||
if (startIndex >= 0)
|
||||
{
|
||||
while (startIndex >= 0 && startIndex < text.Length &&
|
||||
textToLower.Substring(startIndex).Contains(name.ToLower()) && name.Length > 1 && name != name.ToLower())
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (textToLower.Contains(" class="))
|
||||
{
|
||||
var className = new StringBuilder();
|
||||
int startClass = textToLower.IndexOf(" class=");
|
||||
int startClass = textToLower.IndexOf(" class=", StringComparison.Ordinal);
|
||||
int indexClass = startClass + 7;
|
||||
while (indexClass < textToLower.Length && (Utilities.LowercaseLettersWithNumbers + "'\"").Contains(textToLower[indexClass].ToString()))
|
||||
{
|
||||
|
@ -2296,7 +2296,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
foreach (string s in namesEtcMultiWordList)
|
||||
{
|
||||
if (s.Contains(word) && text.Contains(s))
|
||||
if (s.IndexOf(word, StringComparison.Ordinal) >= 0 && text.IndexOf(s, StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
if (s.StartsWith(word + " ") || s.EndsWith(" " + word) || s.Contains(" " + word + " "))
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user