aboutsummaryrefslogtreecommitdiff
path: root/Emby.Naming/Video/CleanStringParser.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Naming/Video/CleanStringParser.cs')
-rw-r--r--Emby.Naming/Video/CleanStringParser.cs33
1 files changed, 7 insertions, 26 deletions
diff --git a/Emby.Naming/Video/CleanStringParser.cs b/Emby.Naming/Video/CleanStringParser.cs
index 051809570..63a595357 100644
--- a/Emby.Naming/Video/CleanStringParser.cs
+++ b/Emby.Naming/Video/CleanStringParser.cs
@@ -25,37 +25,18 @@ namespace Emby.Naming.Video
return false;
}
- // Iteratively remove extra cruft until we're left with the string
- // we want.
- newName = ReadOnlySpan<char>.Empty;
- const int maxTries = 100; // This is just a precautionary
- // measure. Should not be neccesary.
- var loopCounter = 0;
- for (; loopCounter < maxTries; loopCounter++)
+ // Iteratively apply the regexps to clean the string.
+ bool cleaned = false;
+ for (int i = 0; i < expressions.Count; i++)
{
- bool cleaned = false;
- var len = expressions.Count;
- for (int i = 0; i < len; i++)
- {
- if (TryClean(name, expressions[i], out newName))
- {
- cleaned = true;
- name = newName.ToString();
- break;
- }
- }
-
- if (!cleaned)
+ if (TryClean(name, expressions[i], out newName))
{
- break;
+ cleaned = true;
+ name = newName.ToString();
}
}
- if (loopCounter > 0)
- {
- newName = name.AsSpan();
- }
-
+ newName = cleaned ? name.AsSpan() : ReadOnlySpan<char>.Empty;
return newName != ReadOnlySpan<char>.Empty;
}