Skip to content
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

[Question]: Why are interfaces used for private fields? #271

Closed
ds5678 opened this issue Mar 16, 2022 · 3 comments
Closed

[Question]: Why are interfaces used for private fields? #271

ds5678 opened this issue Mar 16, 2022 · 3 comments

Comments

@ds5678
Copy link
Contributor

ds5678 commented Mar 16, 2022

I noticed that some places in the code use an interface as the field type for private fields. One example location is here:

private readonly IDictionary<ITypeDescriptor, TypeDefinition> _typeCache;

As I understand things, interface calls are even less performant than virtual calls, so in this example, using a Dictionary or ConcurrentDictionary would improve performance. Making changes like this across the whole project could be a significant difference.

Is this something that you're open to?

@Washi1337
Copy link
Owner

Short answer: Yes I would be open to changes like these.

Longer answer: A lot of these are leftovers of encapsulations that eventually got demoted back to fields, or are simply the result of a lack of programming knowledge on where to use interfaces and where not to use them. AsmResolver is a project running for a while already, and as it grows, I have learned along the way as well. Some of these redundant abstractions are already removed and concretized into their specific implementations. But as you can see not all of them yet.

@ds5678
Copy link
Contributor Author

ds5678 commented Mar 16, 2022

I'll see what I can find and make a PR.

I'm not judging you. I just want this to be the best it can be.

@Washi1337
Copy link
Owner

Don't worry, I didn't get the impression you were. I am simply giving you the answer to your post title ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants