Performance nightmare

22 to 0.3 seconds!

I found a simple solution to a very common problem. While profiling I found that remove in this little method took a lot of the time.

The reason was, that it’s time consuming to compare the properties by equality, for complex types. I think that in most (?) cases we want to delete the very same instance we supply as parameter to the remove method.

So I implemented a ReferenceEquals based remove, and by that I cut the time spent in remove by about 72 times!

This Post Has 2 Comments

  1. Could you explain the ReferenceEqual method please?

  2. It’s like comparing pointers. Checks that it’s the same instance.

Leave a Reply

Close Menu