Browse Source

Gate the explicit-impl operator check before allocating the short name

The MetadataMethod constructor cut the post-dot short name for every
static non-generic method whose name contains a dot, only to test it
for an op_ prefix that almost never matches. The prefix is now checked
on a span slice first, so the substring (still required by
OperatorDeclaration.GetOperatorType) is allocated only for actual
explicit-interface operator implementations.

Assisted-by: Claude:claude-fable-5:Claude Code
pull/3963/head
Christoph Wille 1 month ago
parent
commit
b71d47f586
  1. 7
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs

7
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs

@ -102,12 +102,13 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -102,12 +102,13 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
// with MethodAttributes.SpecialName or MethodAttributes.RTSpecialName
string name = this.Name;
int index = name.LastIndexOf('.');
if (index > 0)
// Test the op_ prefix on a slice first: this branch runs for every static
// non-generic method, and only operator names warrant the substring.
if (index > 0 && name.AsSpan(index + 1).StartsWith("op_".AsSpan(), StringComparison.Ordinal))
{
name = name.Substring(index + 1);
if (name.StartsWith("op_", StringComparison.Ordinal)
&& CSharp.Syntax.OperatorDeclaration.GetOperatorType(name) != null)
if (CSharp.Syntax.OperatorDeclaration.GetOperatorType(name) != null)
{
this.symbolKind = SymbolKind.Operator;
}

Loading…
Cancel
Save