]> granicus.if.org Git - handbrake/commitdiff
WinGui: AutoName Sort the InvalidFileNameChars Array before doing a Binary Search...
authorsr55 <sr55.hb@outlook.com>
Mon, 26 Jun 2017 19:41:20 +0000 (20:41 +0100)
committersr55 <sr55.hb@outlook.com>
Mon, 26 Jun 2017 19:42:11 +0000 (20:42 +0100)
win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs

index c621612646a07c2bafe4c57f543ed1f0ed243f5c..5d936be0c69e93cf4f3920d13e42301fd76557a8 100644 (file)
@@ -1542,10 +1542,11 @@ namespace HandBrakeWPF.ViewModels
         /// <returns>True if valid</returns>\r
         private bool IsValidAutonameFormat(string input, bool isSilent)\r
         {\r
+            char[] invalidchars = Path.GetInvalidFileNameChars();\r
+            Array.Sort(invalidchars);\r
             foreach (var characterToTest in input)\r
             {\r
-                // we binary search for the character in the invalid set. This should be lightning fast.\r
-                if (Array.BinarySearch(Path.GetInvalidFileNameChars(), characterToTest) >= 0)\r
+                if (Array.BinarySearch(invalidchars, characterToTest) >= 0)\r
                 {\r
                     if (!isSilent)\r
                     {\r