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
Minor allocation optimizations / cleanup #6983
Conversation
return existenceCache.Value.GetOrAdd(directory, Directory.Exists); | ||
} | ||
|
||
public virtual bool FileExists(string file) |
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.
This method was unused.
p => FileUtilities.DirectoryExistsNoThrow(p), | ||
(p, searchPattern) => Directory.GetDirectories(p, searchPattern), | ||
p => AssemblyNameExtension.GetAssemblyNameEx(p), | ||
(string path, ConcurrentDictionary<string, AssemblyMetadata> assemblyMetadataCache, out AssemblyNameExtension[] dependencies, out string[] scatterFiles, out FrameworkNameVersioning frameworkName) |
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 wonder if there's a more concise way of expressing this. My understanding is that if there is an out
parameter then all parameters have to be listed complete with types.
Context
Fixing a few places where we allocated objects unnecessarily. This is by no means exhaustive.
Changes Made
GetOrAdd
should be given a delegate to a method that creates a new object, not the new object itself. Otherwise we allocate and throw away the object in the "Get" case.Testing
Existing unit tests.