-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Further optimize FindValidCloneMethod #48949
Conversation
dotnet#48935 optimizes one path that hits FindValidCloneMethod, but there are others that could do with the same fast-path optimization. In order to accomplish that, I introduced a new HasPossibleCloneMethod on NamedTypeSymbol, that returns whether the type _could_ have a method on it that is a valid clone method. For source types, this is a quick syntax check to see if it's a record. For metadata types, it's a check on just the member names for something with the right name. This should prevent us from unnecessarily loading all method signatures from metadata unnecessarily whenever we check for a clone method.
7d026ce
to
a3ada0c
Compare
@AlekseyTs @dotnet/roslyn-compiler this is ready for review. |
@dotnet/roslyn-compiler for reviews please. |
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
Outdated
Show resolved
Hide resolved
@@ -349,6 +349,7 @@ internal override bool IsInterface | |||
internal sealed override NamedTypeSymbol NativeIntegerUnderlyingType => null; | |||
|
|||
internal override bool IsRecord => false; | |||
internal override bool HasPossibleWellKnownCloneMethod() => false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are records represented in the EE? This line caught me a bit off guard. Must be I don't have the full pictuer here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how records are represented in EE, but this doesn't particularly change whatever it is. @tmat, does EE have records support? If so, we likely need to file a separate bug and make a change here.`
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedContainer.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEmbeddedAttributeSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Wrapped/WrappedNamedTypeSymbol.cs
Outdated
Show resolved
Hide resolved
Done with review pass (iteration 3) #Closed |
… implementations, seal where possible.
@AlekseyTs @jaredpar addressed feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (iteration 4)
#48935 optimizes one path that hits FindValidCloneMethod, but there are others that could do with the same fast-path optimization. In order to accomplish that, I introduced a new HasPossibleCloneMethod on NamedTypeSymbol, that returns whether the type could have a method on it that is a valid clone method. For source types, this is a quick syntax check to see if it's a record. For metadata types, it's a check on just the member names for something with the right name. This should prevent us from unnecessarily loading all method signatures from metadata whenever we check for a clone method