Switch from IndexOf(string) to Contains(string) for better readability and performanc...
authorAndrii Siriak <siryaka@gmail.com>
Fri, 21 Jun 2019 22:25:09 +0000 (01:25 +0300)
committerJan Kotas <jkotas@microsoft.com>
Mon, 24 Jun 2019 21:35:13 +0000 (14:35 -0700)
* Fix performance IndexOf(string) -> Contains(string)

* Make comparison ordinal

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
src/System.Private.CoreLib/shared/Internal/Win32/RegistryKey.cs

index cec8e2f..f66ebf0 100644 (file)
@@ -84,7 +84,7 @@ namespace Internal.Win32
         public RegistryKey? OpenSubKey(string name, bool writable)
         {
             // Make sure that the name does not contain double slahes
-            Debug.Assert(name.IndexOf("\\\\") == -1);
+            Debug.Assert(!name.Contains(@"\\"));
 
             int ret = Interop.Advapi32.RegOpenKeyEx(_hkey,
                 name,