From b71d47f586e3dc3309d028d2acd29771d65e8619 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Fri, 7 Aug 2026 14:50:42 +0200 Subject: [PATCH] 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 --- .../TypeSystem/Implementation/MetadataMethod.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs index 1f69799d0..056bd3f43 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs @@ -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; }