Refactor quotes replacement in FixCommonErrors

Changed the structure and logic of AddMissingQuotes.cs to improve readability and performance. Instead of multiple utility function calls with hardcoded quotes, a constant "doubleQuote" is implemented, and the nested conditions are reorganized for better flow.
This commit is contained in:
Ivandro Jao 2024-02-24 20:30:27 +00:00
parent 1b0d70a562
commit d5190e44b9

View File

@ -243,14 +243,20 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
return text;
}
if (Utilities.CountTagInText(text, "\"") == 1 && Utilities.CountTagInText(text, "”") == 1)
const string doubleQuote = "\"";
if (Utilities.CountTagInText(text, doubleQuote) == 1)
{
return text.Replace("”", "\"");
}
if (Utilities.CountTagInText(text, "\"") == 1 && Utilities.CountTagInText(text, "“") == 1)
{
return text.Replace("“", "\"");
if (Utilities.CountTagInText(text, "”") == 1)
{
return text.Replace("”", doubleQuote);
}
if (Utilities.CountTagInText(text, "“") == 1)
{
return text.Replace("“", doubleQuote);
}
}
return text;
}
}