Check ascii casing in the candidate process (#254)
author조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Mon, 29 Jun 2020 21:51:32 +0000 (06:51 +0900)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Mon, 29 Jun 2020 21:51:32 +0000 (06:51 +0900)
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 "ascii casing check function" may be significantly slowed down.
To avoid that kind situation, call it in advance on the candidate process.

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)