Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Reflection/Module.cs')
-rw-r--r--src/System.Private.CoreLib/shared/System/Reflection/Module.cs42
1 files changed, 9 insertions, 33 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Module.cs b/src/System.Private.CoreLib/shared/System/Reflection/Module.cs
index 56f83c40d..d290f7803 100644
--- a/src/System.Private.CoreLib/shared/System/Reflection/Module.cs
+++ b/src/System.Private.CoreLib/shared/System/Reflection/Module.cs
@@ -130,53 +130,29 @@ namespace System.Reflection
public override string ToString() => ScopeName;
- public static readonly TypeFilter FilterTypeName = FilterTypeNameImpl;
- public static readonly TypeFilter FilterTypeNameIgnoreCase = FilterTypeNameIgnoreCaseImpl;
+ public static readonly TypeFilter FilterTypeName = (m, c) => FilterTypeNameImpl(m, c, StringComparison.Ordinal);
+ public static readonly TypeFilter FilterTypeNameIgnoreCase = (m, c) => FilterTypeNameImpl(m, c, StringComparison.OrdinalIgnoreCase);
private const BindingFlags DefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
// FilterTypeName
// This method will filter the class based upon the name. It supports
// a trailing wild card.
- private static bool FilterTypeNameImpl(Type cls, object filterCriteria)
+ private static bool FilterTypeNameImpl(Type cls, object filterCriteria, StringComparison comparison)
{
// Check that the criteria object is a String object
- if (filterCriteria == null || !(filterCriteria is string))
- throw new InvalidFilterCriteriaException(SR.InvalidFilterCriteriaException_CritString);
-
- string str = (string)filterCriteria;
-
- // Check to see if this is a prefix or exact match requirement
- if (str.Length > 0 && str[str.Length - 1] == '*')
+ if (!(filterCriteria is string str))
{
- str = str.Substring(0, str.Length - 1);
- return cls.Name.StartsWith(str, StringComparison.Ordinal);
- }
-
- return cls.Name.Equals(str);
- }
-
- // FilterFieldNameIgnoreCase
- // This method filter the Type based upon name, it ignores case.
- private static bool FilterTypeNameIgnoreCaseImpl(Type cls, object filterCriteria)
- {
- // Check that the criteria object is a String object
- if (filterCriteria == null || !(filterCriteria is string))
throw new InvalidFilterCriteriaException(SR.InvalidFilterCriteriaException_CritString);
-
- string str = (string)filterCriteria;
-
+ }
// Check to see if this is a prefix or exact match requirement
if (str.Length > 0 && str[str.Length - 1] == '*')
{
- str = str.Substring(0, str.Length - 1);
- string name = cls.Name;
- if (name.Length >= str.Length)
- return (string.Compare(name, 0, str, 0, str.Length, StringComparison.OrdinalIgnoreCase) == 0);
- else
- return false;
+ ReadOnlySpan<char> slice = str.AsSpan(0, str.Length - 1);
+ return cls.Name.AsSpan().StartsWith(slice, comparison);
}
- return (string.Compare(str, cls.Name, StringComparison.OrdinalIgnoreCase) == 0);
+
+ return cls.Name.Equals(str, comparison);
}
}
}