0xd4d / dnlib

Reads and writes .NET assemblies and modules
MIT License
2.14k stars 583 forks source link

Optimize finding CustomAttribute by a full name #527

Closed AlanLiu90 closed 1 year ago

AlanLiu90 commented 1 year ago

This PR improves CustomAttributeCollection.Find, CustomAttributeCollection.FindAll and CustomAttributeCollection.RemoveAll by comparing the suffix of the full name first. It can avoid calling CustomAttribute.TypeFullName in most of the time.

In a workflow I'm using currently, this PR can reduce the total running time by 29%.

wtfsck commented 1 year ago

The args (string fullName) could be null before but will now throw if null so we need a null check at the beginning of the methods now (return early if null).

AlanLiu90 commented 1 year ago

I updated the code to check if fullName is null in these methods.

wtfsck commented 1 year ago

Thanks, merged!