From c55e5ccd410a268689b2dba28004ac106aec7c1e Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Fri, 25 Nov 2016 20:00:16 +0100 Subject: [PATCH] A bit extra performance in last commit + updated change log --- Changelog.txt | 6 ++++++ libse/Utilities.cs | 35 ++++++++++++++++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 4a279ed5a..452651e3f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ * Updated Romanian translation - thx Mircea * Updated Finnish translation - thx Teijo * Updated French Translation - thx JM GBT + * Language auto-detect now includes Latvian and Lithuanian - thx rhazor * FIXED: * Fixed possible crash when generating scene changes - thx Leemet * Fixed issues with moving rules in "Multiple replace" - thx kristiaanvk @@ -17,6 +18,11 @@ * Fixed possible crash in textbox with italic - thx ivandrofly * Fixed bug in file naming after extracting sub from mkv - thx mzso * Fixed bottom margin in image export of SSA/ASS - thx maddox + * "Find" always try to find the next occurrence - thx Boulder08 + * Fixed "Remove text for HI" issue reagarding colons - thx Boulder08 + * Fix "Fix missing spaces" issue regarding Finnish/Swedish colons - thx Boulder08 + * Fix two issues with "Fix common errors" - thx Tronar + * OCR fix rules: fix for weird Unicode comma (#x201A) - thx djc 3.5 (26th October 2016) diff --git a/libse/Utilities.cs b/libse/Utilities.cs index b60d348f5..c57955bf0 100644 --- a/libse/Utilities.cs +++ b/libse/Utilities.cs @@ -1207,8 +1207,7 @@ namespace Nikse.SubtitleEdit.Core { return s; } - char[] chars = new char[len]; - // O(n) + var chars = new char[len]; for (int i = 0; i < len; i++) { chars[i] = s[len - i - 1]; @@ -1223,26 +1222,24 @@ namespace Nikse.SubtitleEdit.Core return s; } int len = s.Length; - char[] chars = new char[len]; - // O(n) - for (int i = len - 1; i >= 0; i--) + var chars = new char[len]; + for (int i = 0; i < len; i++) { char ch = s[i]; - if (ch == '(') + switch (ch) { - ch = ')'; - } - else if (ch == ')') - { - ch = '('; - } - else if (ch == '[') - { - ch = ']'; - } - else if (ch == ']') - { - ch = '['; + case '(': + ch = ')'; + break; + case ')': + ch = '('; + break; + case '[': + ch = ']'; + break; + case ']': + ch = '['; + break; } chars[i] = ch; }