From 07be8bd1908bc812a223604e1133666115947b07 Mon Sep 17 00:00:00 2001 From: ivandrofly Date: Sat, 28 Feb 2015 23:30:13 +0000 Subject: [PATCH] Some optimization in RemoveEmptyLines --- src/Logic/Subtitle.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Logic/Subtitle.cs b/src/Logic/Subtitle.cs index 67a23039c..460717507 100644 --- a/src/Logic/Subtitle.cs +++ b/src/Logic/Subtitle.cs @@ -458,8 +458,8 @@ namespace Nikse.SubtitleEdit.Logic public int RemoveEmptyLines() { - int count = 0; - if (_paragraphs.Count > 0) + int count = _paragraphs.Count; + if (count > 0) { int firstNumber = _paragraphs[0].Number; for (int i = _paragraphs.Count - 1; i >= 0; i--) @@ -468,14 +468,12 @@ namespace Nikse.SubtitleEdit.Logic string s = p.Text.Trim(); if (s.Length == 0) - { _paragraphs.RemoveAt(i); - count++; - } } - Renumber(firstNumber); + if (count != _paragraphs.Count) + Renumber(firstNumber); } - return count; + return count - _paragraphs.Count; } ///