From 907b3185c288c38a398c2e6498f43bcce18c6ee9 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sun, 1 Sep 2019 21:43:25 -0400 Subject: [PATCH] Use regex to replace multiple spaces with one space This communicates the intent of the code more clearly than before. No noticeable performance impact. --- .../TV/TheTVDB/TvdbSeriesProvider.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index 7c105599da..10ed4f0731 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Net; @@ -312,14 +313,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB } sb.Replace(", the", string.Empty).Replace("the ", " ").Replace(" the ", " "); - int prevLength; - do - { - prevLength = sb.Length; - sb.Replace(" ", " "); - } while (sb.Length != prevLength); - - return sb.ToString().Trim(); + return Regex.Replace(sb.ToString().Trim(), @"\s+", " "); } private void MapSeriesToResult(MetadataResult result, TvDbSharper.Dto.Series tvdbSeries, string metadataLanguage)