From eb0359cb975a2e6b4fdc17f07e3a7d35ab9200f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=A1=B0=EC=9B=85=EC=84=9D/Common=20Platform=20Lab=28SR=29?= =?utf8?q?/Principal=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 30 Jun 2020 06:51:32 +0900 Subject: [PATCH] Check ascii casing in the candidate process (#254) 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. Change-Id: I46509deec025f724b8fdb3bfd81431e08e611209 --- Managed/Tizen.Runtime/Preloader.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Managed/Tizen.Runtime/Preloader.cs b/Managed/Tizen.Runtime/Preloader.cs index f0ed99e..5a9f132 100644 --- a/Managed/Tizen.Runtime/Preloader.cs +++ b/Managed/Tizen.Runtime/Preloader.cs @@ -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) -- 2.7.4