FNA-XNA / FNA

FNA - Accuracy-focused XNA4 reimplementation for open platforms
https://fna-xna.github.io/
2.61k stars 265 forks source link

Use weak GCHandles instead of WeakReference instances for GraphicsResource #452

Closed kg closed 11 months ago

kg commented 11 months ago

WeakReference is an extra heap allocation per resource that basically exists to give us a finalizer - but we already have one, so we can just use GCHandle directly.

Since the default List.Remove would box the handles to compare them I had to do the Remove manually, but that allows doing an unordered remove anyway for a slight speed boost (that doesn't matter because nobody disposes resources that often)