Check ascii casing in the candidate process (#254)
[platform/core/dotnet/launcher.git] / Managed / Tizen.Runtime / Preloader.cs
index f0ed99e..5a9f132 100644 (file)
@@ -18,14 +18,27 @@ using System;
 using System.IO;
 using System.Reflection;
 using System.Runtime.Loader;
+using System.Globalization;
 
 namespace Tizen.Runtime
 {
     public class Preloader
     {
         const string preloadPath = "/usr/share/dotnet.tizen/preload/";
+
+        // If current culture's casing for ASCII is the same as invariant, it can take a fast path
+        // than calling out to the OS for culture-aware casing.
+        // However, in certain languages, the following function may be significantly slowed down.
+        // To avoid that kind situation, call it in advance on the candidate process.
+        private static void CheckAsciiCasing()
+        {
+            _ = CultureInfo.CurrentCulture.CompareInfo.Compare("abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", CompareOptions.IgnoreCase);
+        }
+
         public static void Preload()
         {
+            CheckAsciiCasing();
+
             string[] paths = Directory.GetFiles(preloadPath, "*.preload");
             Array.Sort(paths);
             foreach (string path in paths)